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

int main(void) {
  int N;
  string S;
  cin >> N >> S;
  int ans = 1;
  char pre = S[0];
  for (int i = 1; i < N; i++) {
    if (pre != S[i]) {
      ans++;
      pre = S[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 200010
 
#define PI   3.14159265358979323846264338327950
 
#define PB push_back 
#define F first
#define S second
 
#define ll 	long long  int 
 
#define mod  1000000007


int main()
{
	FAST;
	ll n;
	cin >> n ;
	ll a[n+4];
	for(ll i = 0; i < n; i ++){
		cin >> a[i];
	}
	sort(a, a + n);
	ll x = 0;
	for(ll i = 0; i < n-1; i ++){
		x += a[i];
	}
	x += (a[n-1] / 2);
	cout << x;
	return 0;
}

Measured memory_bytes: 3664
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=2e5+5;
inline ll sgn(R ll x){return x<0?-1:x>0;}
ll tmp;
struct node{
	int u,x,y;
	inline node(){}
	inline node(R int uu,R int xx,R int yy):u(uu),x(xx),y(yy){}
	inline bool operator <(const node &b)const{
		if(sgn(tmp=1ll*x*b.y-1ll*y*b.x))return tmp<0;
		return y<b.y;
	}
};priority_queue<node>q;
int fa[N],ga[N],vis[N],sa[N],sb[N],n,now;ll f[N],res;
int find(int x){return ga[x]==x?x:ga[x]=find(ga[x]);}
inline void merge(int u,int v){ga[find(u)]=find(v);}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n);
	fp(i,1,n)ga[i]=i;
	fp(i,2,n)scanf("%d",&fa[i]);
	for(R int i=1,x;i<=n;++i){
		scanf("%d",&x);
		q.push(x?(++sb[i],node(i,0,1)):(++sa[i],node(i,1,0)));
	}
	vis[0]=1;
	while(!q.empty()){
		R node p=q.top();q.pop();
		if(vis[p.u]||p.x!=sa[p.u]||p.y!=sb[p.u])continue;
		R int u=p.u,v;vis[u]=1;
//		printf("%d %d %d %d\n",u,sa[u],sb[u],now);
		if(vis[find(fa[u])])res+=f[u]+1ll*now*sa[u],now+=sb[u];
		else{
			v=find(fa[u]),merge(u,v);
			f[v]+=f[u]+1ll*sb[v]*sa[u],sa[v]+=sa[u],sb[v]+=sb[u];
			q.push(node(v,sa[v],sb[v]));
		}
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 8944
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var X = input[0];
            var Y = input[1];
            var Z = input[2];

            Console.WriteLine($"{Z} {X} {Y}");
        }
    }
}


Measured memory_bytes: 13396
from copy import copy
n = int(input())
a = [int(i) for i in input().split()]
count_a = {}
diff_a = [0] * n
for ai in a:
    try:
        count_a[ai] += 1
    except KeyError:
        count_a[ai] = 1

for i in range(n):
    diff_a[i] = (count_a[a[i]] - 1)

count = 0    
for v in count_a.values():
    count += v*(v - 1) // 2
for i in range(n):
    count_copy = copy(count)
    print(count_copy - diff_a[i])

Measured memory_bytes: 26780
using System;

namespace AtCoder
{
    class Program
    {
        static IO io = new IO();

        static void Main(string[] args)
        {
            io.ReadSplit();
            int A = io.Int();
            int B = io.Int();
            int C = io.Int();

            io.WriteLine(YN(A, B, C));
        }

        private static string YN(int A, int B, int C)
        {
            for (int i = 1; i <= B; ++i)
            {
                if ((A * i) % B == C)
                {
                    return "YES";
                }
            }
            return "NO";
        }
    }
    class IO
    {
        private string[] _Inputs;
        private int _Index;
        public void Read()
        {
            _Inputs = new string[1];
            _Inputs[0] = Console.ReadLine();
            _Index = 0;
        }
        public void ReadSplit()
        {
            _Inputs = Console.ReadLine().Split(' ');
            _Index = 0;
        }
        public string String()
        {
            return _Inputs[_Index++];
        }
        public string[] String(int xCount)
        {
            string[] rv = new string[xCount];
            Array.Copy(_Inputs, _Index, rv, 0, xCount);
            _Index += xCount;
            return rv;
        }
        public int Int()
        {
            return int.Parse(_Inputs[_Index++]);
        }
        public int[] Int(int xCount)
        {
            int[] rv = new int[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = int.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public long Long()
        {
            return long.Parse(_Inputs[_Index++]);
        }
        public long[] Long(int xCount)
        {
            long[] rv = new long[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = long.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public void Write(string xStr)
        {
            Console.Write(xStr);
        }
        public void WriteLine(string xStr)
        {
            Console.WriteLine(xStr);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int n;
    cin >> n;
    map<int, int> v;
    for (int i = 0; i < n; ++i) {
        int k;
        scanf("%d",&k);
        v[k]++;
    }
    int a = 0, b = 0;
    for (auto &&x : v) {
        if(x.second%2)a++;
        else if(x.second%2 == 0 && x.second > 0) b++;
    }
    cout << a + b/2*2 << "\n";
    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
	int a;
	cin >> a;

	if (a == 7 || a == 5 || a == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

class ANextAlphabet {
public:
	void solve(std::istream& in, std::ostream& out) {
	    char c;
	    s(c);
	    c++;
	    out<<c<<endl;

	}
};


integer main() {
	ANextAlphabet solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,ll> pil;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;

namespace io{
    const int L = (1 << 20) + 1;

    char buf[L], *S , *T, c;

    char getchar() {
        if(__builtin_expect(S == T, 0)) {
            T = (S = buf) + fread(buf, 1, L, stdin);
            return (S == T ? EOF : *S++);
        }
        return *S++;
    }

    int inp() {
        int x = 0, f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }

    unsigned inpu()
    {
        unsigned x = 0; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar());
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x;
    }

    ll inp_ll() {
        ll x = 0; int f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }

    char B[25], *outs=B+20, *outr=B+20;
    template<class T>
    inline void print(register T a,register char x=0){
        if(x) *--outs = x, x = 0;

        if(!a)*--outs = '0';
        else
            while(a)
                *--outs = (a % 10) + 48, a /= 10;

        if(x)
            *--outs = x;

        fwrite(outs, outr - outs , 1, stdout);
        outs = outr;
    }
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;
const int maxN = 1e5;
int a[maxN];
int main()
{
	for(int i=1;i<=3;i++)
	{
		int x = inp();
		int y = inp();
		a[x] ++;
		a[y] ++;
	}
	int c1 = 0,c2 = 0;
	for(int i=1;i<=4;i++)
	{
		if(a[i] == 1)
			c1++;
		else if(a[i] == 2)
		{
			c2++;
		}
	}
	if(c1 == 2 && c2==2)
	{
		puts("YES");
	}
	else
	{
		puts("NO");
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  ll x, y;
  cin >> x >> y;
  for(int a = 1;;++a) {
    if(x*(ll)pow(2, a-1) > y) {
      cout << a-1 << endl;
      return 0;
    }
  }
}

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

int main() {
  string s;
  int cnt = 0;
  cin >> s;
  for(int i = 0; i < s.length() / 2; i++)
    if(s.at(i) != s.at(s.length() - 1 - i))
      cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 256
n, y = gets.chomp.split.map(&:to_i)

a = 0
clear = 0
while a <= y / 10000
  b = 0
  while b <= (y-a*10000)/5000 && a+b <= n
    if a*10000 + b*5000 + (n-a-b)*1000 == y
      clear = 1
      break
    end
    b += 1
  end
  break if clear == 1
  a += 1
end

puts clear == 1 ? "#{a} #{b} #{n-a-b}" : "-1 -1 -1"

Measured memory_bytes: 1788
def main():
    N = int(input())
    S = input()
    from collections import Counter
    c = Counter(S)
    ans = 1 if len(c.keys()) > 2 else 0
    for v in c.values():
        ans *= v
    less = 0
    for d in range(1, N+1):
        for i in range(N):
            if i+d < N and i+2*d < N and \
                    S[i] != S[i+d] and S[i] != S[i+2*d] and S[i+d] != S[i+2*d]:
                less += 1
    print(ans - less)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68808
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	vector<int> heights(n); fore(e, heights) cin >> e;
	int curmax = heights[0], ans = 0;
	forl(i, 0, n) {
		curmax = max(curmax, heights[i]);
		if(heights[i] >= curmax) ans++;
	}
	println(ans);
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		int result = 0;
		int max = 100;
		
		long[] res = new long[n+1];
		for(int i = 1; i <= max; i++){
		    for(int j = 1; j <= max; j++){
		        for(int k = 1; k <= max; k++){
		            long tmp = i*i+j*j+k*k+i*j+j*k+k*i;
		            if(tmp < n+1) res[(int)tmp]++;
		        }
		    }
		}
		
		for(int i = 1; i <= n; i++){
		    System.out.println(res[i]);
		}
		

		// 出力
		//System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
	
}



Measured memory_bytes: 28596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a<=c){
    if(b<=c){
      cout<<0<<endl;
    }else{
      if(b<=d){
        cout<<b-c<<endl;
      }else{
        cout<<d-c<<endl;
      }
    }
  }else if(a>c){
    if(a>d){
      cout<<0<<endl;
    }else{
      if(b<=d){
        cout<<b-a<<endl;
      }else{
        cout<<d-a<<endl;
      }
    }
  }

}


Measured memory_bytes: 256
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce
import bisect

MOD = 10**9 + 7
INF = float('inf')

K = int(input())
S = input()

if len(S) <= K:
    print(S)
else:
    print(S[:K]+"...")


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

int main()
{
    int n;
    cin>>n;
    double k;
    string s;
    double sum=0;
    while(n--)
    {
        cin>>k>>s;
        if(s=="JPY")
        sum+=k;
        else
        {
            sum+=k*380000.0;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a,b,c,i,j,k;
    string s,d;
    cin>>a>>s>>d;
    for(i=0;i<a;i++)
    {
        cout<<s[i]<<d[i];
    }
}


Measured memory_bytes: 384
h,w=map(int,input().split())
field=[list(input())for i in range(h)]

import copy
dp=[[1000 for i in range(w)]for i in range(h)]
for y,i in enumerate(field):
    for x,j in enumerate(i):
        if j=="#":
            dp[y][x]=9999

dydx=[[-1,0],[1,0],[0,-1],[0,1]]
#print(dp)
maxi=0
for y,i in enumerate(field):
    for x,j in enumerate(i):
        if j==".":
            ndp=copy.deepcopy(dp)
            ndp[y][x]=0
            cnt=0
            queue=[]
            queue.append([y,x])
            while queue:
                ny,nx=queue.pop(0)
                for dy,dx in dydx:
                    nny,nnx=ny+dy,nx+dx
                    if 0<=nny<=h-1 and 0<=nnx<=w-1 and field[nny][nnx]!="#" and ndp[nny][nnx]==1000:
                        ndp[nny][nnx]=ndp[ny][nx]+1
                        queue.append([nny,nnx])
                        if ndp[nny][nnx]>maxi:
                            maxi=ndp[nny][nnx]
            #print(ndp)
print(maxi)

Measured memory_bytes: 3540
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b) {
    long long diff = *(long long *)a - *(long long *)b;
    return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
}

int main() {
    
    int i, j, N, M;
    long long a[100001], v = 0, r;
    
    scanf("%d %d", &N, &M);
    
    a[0] = 0;
    for (i = 1; i <= N; i++) {
        scanf("%lld", &a[i]);
        a[i] += a[i - 1];
        a[i] %= M;
    }
    
    qsort(a + 1, N, sizeof(long long), compare);
    
    for (i = 1, j = 0; i <= N; i++) {
        if (a[i] != a[j]) {
            r = i - j;
            v += r * (r - 1) / 2;
            j = i;
        }
    }
    r = i - j;
    v += r * (r - 1) / 2;
    
    printf("%lld\n", v);
    
    return 0;
    
}

Measured memory_bytes: 1788
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

using namespace std;

int main(void){
  int N;
  cin>>N;

  vector<int> X(N+1);
  FORQ(i,1,N){
    cin>>X[i];
  }

  vector<int> Y(N);
  FORQ(i,0,N-1){
    Y[i]=X[i+1];
  }

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

  vector<int> A(N+1);
  FORQ(i,1,N){
    A[i]=Y[i-1];
  }

  int l1,l2;
  l1=A[N/2];
  l2=A[N/2+1];

  FORQ(i,1,N){
    if(X[i]>=l2){
      cout<<l1<<endl;
    }else if(X[i]<=l1){
      cout<<l2<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 4480
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main() {
    int n;
    uint64_t a = 2, l0 = 2, li = 1, t;
    cin >> n;
    if (n < 2) {
        if (n == 0) a = l0;
        else a = li;
        cout << a << endl;
        return 0;
    }
    for (int i=0; i<n-1; i++) {
        a = li + l0;
        t = li;
        li = a;
        l0 = t;
    }
    cout << a << endl;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;

string to_upper(string str) {
    int diff = 'a' - 'A';
    for (int i = 0; i < str.size(); i++) {
        char c = str[i];
        if ('A' <= c && c <= 'Z') {
            c += diff;
            str[i] = c;
        }
    }
    return str;
}

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

        if (s == "-") return 0;

        int n;
        cin >> n;

        rep(i, n) {
            int h;
            cin >> h;
            string front = s.substr(0, h);
            string back = s.substr(h);

            s = back + front;
        }

        cout << s << endl;
    }

}



Measured memory_bytes: 3232
#include <iostream>
#include <algorithm>
using namespace std;
int n,c,k,t[100001],tk,ans=0;
int main()
{
	cin>>n>>c>>k;
	for(int i=0;i<n;i++)cin>>t[i];
	sort(t,t+n);
	for(int i=n-1;i>-1;)
	{
		tk=t[i],ans++;
		for(int i2=0;i2<c&&i>-1;i2++)
		{
			i--;
			if(t[i]<tk-k)break;
		}
	}
	cout << ans<<"\n";
}

Measured memory_bytes: 640
from bisect import bisect_left
a, b, q = map(int, input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
s.sort()
t.sort()
xs = [int(input()) for i in range(q)]

for x in xs:
    right_s = bisect_left(s, x)
    right_t = bisect_left(t, x)
    left_s = right_s-1
    left_t = right_t-1
    if right_s == 0:
        left_s = 0
    if right_t == 0:
        left_t = 0
    if right_s == a:
        right_s -= 1
    if right_t == b:
        right_t -= 1
    
    ss = [s[left_s], s[right_s]]
    tt = t[left_t], t[right_t]
    ans = float("inf")
    for i in ss:
        for j in tt:
            ans = min(ans, abs(i-j) + min(abs(i-x), abs(j-x)))
    print(ans)


Measured memory_bytes: 16152
using System;
using System.Linq;

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var arr = new Card[n];

            for(var i = 0; i < n; ++i)
            {
                var sp = Console.ReadLine().Split(' ');
                arr[i] = new Card(int.Parse(sp[1]), sp[0], i);
            }
            QuickSort(ref arr, 0, arr.Length - 1);

            bool isStable = true;
            for(var i = 0; i < n - 1; ++i)
            {
                for(var k = i + 1; k < n && arr[i].Number == arr[k].Number; ++k)
                {
                    if(arr[i].InputOrder > arr[k].InputOrder)
                    {
                        isStable = false;
                        break;
                    }
                }
                if (!isStable) break;
            }
            Console.WriteLine(isStable ? "Stable" : "Not stable");
            Console.WriteLine(string.Join<Card>("\n", arr));
        }

         private static void QuickSort<T>(ref T[] arr, int p, int r) where T : IComparable<T>
        {
            if(p < r)
            {
                var q = Partition(ref arr, p, r);
                QuickSort(ref arr, p, q - 1);
                QuickSort(ref arr, q + 1, r);
            }
        }

        private class Card : IComparable<Card>
        {
            public int Number { private set; get; }
            public string Suit { private set; get; }
            public int InputOrder { private set; get; }

            public Card(int n, string s, int o)
            {
                Number = n;
                Suit = s;
                InputOrder = o;
            }

            public int CompareTo(Card other)
            {
                if (Number < other.Number) return -1;
                if (Number > other.Number) return 1;
                return 0;
            }

            public override string ToString()
            {
                return $"{Suit} {Number}";
            }
        }

        private static int Partition<T>(ref T[] arr, int p, int r) where T : IComparable<T>
        {
            var x = arr[r];
            var i = p - 1;
            for(var k = p; k < r; ++k)
            {
                if(arr[k].CompareTo(x) < 1)
                {
                    ++i;
                    Swap(ref arr[i], ref arr[k]);
                }
            }
            Swap(ref arr[i + 1], ref arr[r]);
            return i + 1;
        }

        private static void Swap<T>(ref T v1, ref T v2)
        {
            var tmp = v1;
            v1 = v2;
            v2 = tmp;
        }
    }
}


Measured memory_bytes: 30564
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
			int a=scan.nextInt();
			int b=scan.nextInt();
			int d,r;
			double f;
			d=a/b;
			r=a%b;
			f=1.0*a/b;
			System.out.println(String.format("%d %d %.8f",d,r,f));
		scan.close();
}
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < (int) s.size(); i++) {
    if (s[i] == ',') s[i] = ' ';
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<pair<ll,ll>>a;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		a.push_back(make_pair(y,x));
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	vector<pair<ll,ll>>b;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		b.push_back(make_pair(x,y));
	}
	ll ans=0;
	sort(b.begin(),b.end());
	for(ll i=0;i<n;i++){
		ll nowx=b[i].first;
		ll nowy=b[i].second;
		for(ll j=0;j<a.size();j++){
			if(a[j].second>nowx){
				continue;
			}
			if(a[j].first<nowy){
				ans++;
				a.erase(a.begin()+j);
				break;
			}
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

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

    while(true){
        int n; cin>>n;
        if(n==0)break;
        vector<Int> a(n,0); for (int i = 0; i < n; i++)cin>>a[i];
        Int ave=accumulate(a.begin(), a.end(),0)/n;
        int ans=0;
        for (int i = 0; i < n; i++) if(a[i]<=ave)ans++;
        cout<<ans<<'\n';
    }
}


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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> x(n);
	rep(i,n){
		cin >> x[i];
	}
	int ans = 0;
	rep(i,n){
		ans += min(2*x[i], 2*abs(k-x[i]));
	}
	cout << ans << endl;
    return 0;
}



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

long long int dp[51][2*50*50+1];
int n,a;
int x[51];
int XX;

int main() {

    cin >> n >> a;

    XX = a;

    for(int i=1; i<=n; i++){
        cin >> x[i];
        x[i] -= a;
        XX = max(XX,x[i]);
    }

    dp[0][n*XX] = 1;

    for(int i=1; i<=n; i++){
        for(int j=0; j<=n*2*XX; j++){
            dp[i][j] += dp[i-1][j];
            if(j-x[i] <= 2*n*XX){
                dp[i][j] += dp[i-1][j-x[i]];
            }
        }
    }

    long long int ans = dp[n][n*XX] - 1;

    cout << ans << endl;

    return 0;
}

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

int main(){
  string S;
  cin >>S;
  int sum = 700;
  
  if(S[0]=='o') sum+=100;
  if(S[1]=='o') sum+=100;
  if(S[2]=='o') sum+=100;
  
  int ans = sum;
  cout <<ans<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
    ll n, m;
    cin >> n >> m;
    ll x[m], y[m];
    for (ll i = 0; i < m;i++){
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
    bool red[n];
    ll all[n];
    for (ll i = 0; i < n;i++){
		if(i==0){
            red[i] = true;
            all[i] = 1;
        }
		else{
            red[i] = false;
            all[i] = 1;
        }
    }
    for (ll i = 0; i < m;i++){
		if(red[x[i]]){
            red[y[i]] = true;
		    all[x[i]]--;
			all[y[i]]++;
            if (all[x[i]] == 0) red[x[i]] = false;
        }
		else {
		    all[x[i]]--;
			all[y[i]]++;
		}
    }
    ll cnt = 0;
    for (ll i = 0; i < n;i++){
        if (red[i]) cnt++;
    }
    cout << cnt << endl;
}

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

const int SIZE=5010;
const int INF=1001001001;

vector<int> G[SIZE];
int cost[SIZE];
bool vis1[SIZE];
bool vis2[SIZE];

int mincost;

void calc_min(int v){
    vis1[v]=true;
    mincost=min(mincost, cost[v]);
    for(int u:G[v]){
        if(!vis1[u]){
            calc_min(u);
        }
    }
}

void set_min(int v){
    vis2[v]=true;
    cost[v]=mincost;
    for(int u:G[v]){
        if(!vis2[u]){
            set_min(u);
        }
    }
}

int main()
{
    int N; cin>>N;
    map<string,int> id;
    for(int i=0;i<N;i++){
        string s; cin>>s;
        int x; cin>>x;
        id[s]=i;
        cost[i]=x;
    }
    int M; cin>>M;
    for(int i=0;i<M;i++){
        string s, t; cin>>s>>t;
        int v=id[s];
        int u=id[t];
        G[v].push_back(u);
        G[u].push_back(v);
    }

    for(int i=0;i<N;i++){
        if(!vis1[i]){
            mincost=INF;
            calc_min(i);
            set_min(i);
        }
    }
    int ans=0;
    for(int i=0;i<N;i++){
        ans+=cost[i];
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3948
// AOJ 1182 Railway Connection
// 2018.2.22 bal4u
 
#include <stdio.h>
#include <string.h>

#define QMAX 10000
typedef struct { int t; int s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x10101010
#define MAX 20001

int d[22][102][102];
int p[22], q[22][52], r[22][52];
int hi[102], to[102][204], w[102][204];
int dist[102], fare[22][20010];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	while (c <= ' ') c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int dijkstra(int s, int g)
{
	int i, e, d;

	memset(dist, INF, sizeof(dist));
	qsize = 0;
	enq(s, 0), dist[s] = 0;
	while (qsize) {
		s = que[0].s, deq();
		if (s == g) return dist[g];
		for (i = 0; i < hi[s]; i++) {
			e = to[s][i], d = dist[s] + w[s][i];
			if (d < dist[e]) dist[e] = d, enq(e, d);
		}
	}
	return -1;
}

int main()
{
	int N, M, C, S, G, i, j, k;
	int x, y, c, t;

	while (N = in()) {
		M = in(), C = in(), S = in()-1, G = in()-1;

		memset(d, INF, sizeof(d));
		for (c = 0; c < C; c++) for (i = 0; i < N; i++) d[c][i][i] = 0;

		for (i = 0; i < M; i++) {
			x = in()-1, y = in()-1, t = in(), c = in()-1;
			if (t < d[c][x][y]) d[c][x][y] = d[c][y][x] = t;
		}

		for (c = 0; c < C; c++) {
			for (k = 0; k < N; k++) for (i = 0; i < N; i++) if (d[c][i][k] < INF) {
				for (j = 0; j < N; j++) if (d[c][k][j] < INF) {
					t = d[c][i][k] + d[c][k][j];
					if (t < d[c][i][j]) d[c][i][j] = t;
				}
			}
		}

		for (c = 0; c < C; c++) p[c] = in();
		for (c = 0; c < C; c++) {
			for (i = 1; i < p[c]; i++) q[c][i] = in();
			q[c][p[c]] = MAX-1;
			for (i = 1; i <= p[c]; i++) r[c][i] = in();
		}

		if (!M) { puts(S == G? "0": "-1"); continue; }

		for (c = 0; c < C; c++) {
			for (i = 1; i <= p[c]; i++) for (j = q[c][i-1]+1; j <= q[c][i]; j++)
				fare[c][j] = fare[c][j-1] + r[c][i];
		}

		memset(hi, 0, sizeof(hi));
		for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
			t = INF;
			for (c = 0; c < C; c++) if (d[c][i][j] < MAX) {
				if (t > (k=fare[c][d[c][i][j]])) t = k;
			}

			if (t < INF) {
				k = hi[i]++, to[i][k] = j, w[i][k] = t;
				k = hi[j]++, to[j][k] = i, w[j][k] = t;
			}
		}
		printf("%d\n", dijkstra(S, G));
	}
	return 0;
}



Measured memory_bytes: 4364
//
//  C - Traveling.cpp
//  atcoder regular contest 089
//
//  Created by Huang,Zhiqiang on 2018/2/17.
//  Copyright © 2018年 Huang,Zhiqiang. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    int prev_x = 0, prev_y = 0, prev_t = 0;
    for (int i = 0; i < N; i++) {
        int x, y, t;
        cin >> t >> x >> y;
        int rest = t - prev_t - abs(x - prev_x) - abs(y - prev_y);
        if (rest < 0 || rest % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
        prev_x = x;
        prev_y = y;
        prev_t = t;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;

int n;
int a[N];

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

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

int tmp[N], cnt;
int pos[N], dir[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    int l = 1, r;
    while(1) {
        while(l <= n && a[l] == l) ++l;
        if(l > n) YES();
        r = l;
        while(1) {
            if((r - l + 1) & 1) {
                if(a[r] != r) ++r;
                else break;
            } else {
                if(a[r] == r) ++r;
                else break;
            }
            if(r > n) break;
        }
        --r; if((r - l) & 1) --r;
        if(l == r) NO();
        cnt = 0;
        for(int i = l; i <= r; i++) tmp[++cnt] = a[i];
        sort(tmp + 1, tmp + cnt + 1);
        for(int i = 1; i <= cnt; i++) if(tmp[i] != i + l - 1) NO();
        cnt = 0;
        for(int i = l; i <= r; i += 2) {
            tmp[++cnt] = a[i]; pos[a[i]] = i;
        }
        sort(tmp + 1, tmp + cnt + 1);
        for(int i = 1; i <= cnt; i++) {
            dir[pos[tmp[i]]] = 2 * i + l - 2;
        }
        int lastl = 0, lastr = n + 1;
        for(int i = l; i <= r; i += 2) {
            if(dir[i] > i) continue;
            if(dir[i] > lastl) lastl = dir[i];
            else NO();
        }
        for(int i = r; i >= l; i -= 2) {
            if(dir[i] < i) continue;
            if(dir[i] < lastr) lastr = dir[i];
            else NO();
        }
        l = r + 1;
    }
    return 0;
}


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

int main() {
  int n;cin>>n;
  int v[n]; for(int i=0;i<n;i++)cin>>v[i];
  ll ans = 0;
  for (int i=0;i<n-1;i++){
    for (int j=i+1;j<n;j++){
      ans += v[i] * v[j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

char s[100005];

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    scanf("%s", s);
    int cur = 0, res = 0, i = 0, j = 0, t = 0;
    while (i < N && j < N) {
        int k = j;
        while (k < N && s[j] == s[k]) ++k;
        cur += (k - j);
        if (s[j] == '0') {
            ++t;
            j = k;
            k = j;
            while (k < N && s[j] == s[k]) ++k;
            cur += (k - j);
            j = k;
        } else {
            j = k;
        }
        if (t > K) {
            k = i;
            while (k < N && s[i] == s[k]) ++k;
            cur -= (k - i);
            if (s[i] == '1') {
                i = k;
                k = i;
                while (k < N && s[i] == s[k]) ++k;
                cur -= (k - i);
                i = k;
            } else {
                i = k;
            }
        }
        res = max(res, cur);
    }
    printf("%d\n", res);
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b;cin >> n >> a >> b;
  if((b-a)%2==0){
    cout << (b-a)/2 << endl;
  }
  else{
    long long ans=min(a-1+1+(b-a-1)/2,n-b+1+(b-a-1)/2);
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, h, w;
int a[1010], b[1010];

int solve() {
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] >= h && b[i] >= w)
            res++;
    }
    return res;
}

void input() {
    cin >> n >> h >> w;
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
}

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

    input();
    cout << solve() << endl;
}


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

int main(){
    long long n,m,x;
    cin >> n >> m >> x;
    long long c[n];
    long long a[n][m];
    for(long long i=0;i<n;i++){
        cin >> c[i];
        for(long long j=0;j<m;j++) cin >> a[i][j];
    }
    bool flag=false;
    long long ans=1e9;
    for(int bit=0;bit < (1<<n);bit++){
        vector<long long> d(m,0);
        long long com=0;
        long long count=0;
        for(long long i=0;i<n;i++){
            if(bit & (1<<i)){
                com+=c[i];
                for(long long j=0;j<m;j++){
                    d[j]+=a[i][j];
                }
            }
        }
        for(long long j=0;j<m;j++){
            if(d[j]>=x){
                count++;
            }
        }
        if(count==m){
            flag=true;
            ans=min(ans,com);
        }
    }
    if(flag) cout << ans << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, r;
    cin >> n >> r;
    if(n < 10){
        cout << r + 100 * (10 - n) << endl;
    }
    else{
        cout << r << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll h,w; cin >> h >> w;
    vector<string> s(h);
    for (ll i = 0;i<h;i++) {
        string a; cin >> a;
        s.at(i) = a;
    }

    string kabe;
    for (ll i = 0;i<w+2;i++) {
        kabe.push_back('#');
    }
    cout << kabe << endl;
    for (ll i = 0;i<h;i++) {
        cout << '#' << s.at(i) << '#' << endl;
    }
    cout << kabe << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//cin.ignore();//better to use 2 times getline(cin,s);
// g++ iterator.cpp -std=c++17
//cout<<(A + B == C ? "YES" : "NO")<<endl;
//__gcd(a,b)
// string s=to_string(i);
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


bool pali(string s)
{
	for(int i=0;i<s.size/2;i++)
	{
		if(s[i] == s[(s.size)-i-1])
		{
			// cout<<s[i]<<endl;
			// cout<<s[s.size-i-1]<<endl;
			// continue;
		}
		else
		{
			return false;
		}
	}
	return true;
}

int main(void)
{
   fast();
   string s;
   cin>>s;
   if(pali(s)==true && s.size%2==1)
   {

   string p = "";
   string q = "";
   int l = s.size;
   for(int i=0;i<(l-1)/2;i++)
   {
   	  p = p+s[i];
   }
      // cout<<p<<endl;   
   for(int i=((l+3)/2)-1;i<l;i++)
   {
   	  q = q+s[i];
   }
    // cout<<q<<endl;

    bool aps = pali(p);
    bool aps2 = pali(q);

   if(aps== true && aps2==true && aps==aps2)
   {
   	  cout<<"Yes"<<endl;
   	  return 0;
   }
   else
   {
   	  cout<<"No"<<endl;
   	  return 0;
   }
}
	else 
	{
		cout<<"No"<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        long sumA = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            sumA += a[i];
        }
        long sumB = 0;
        List<Integer> notPassIdxList = new ArrayList<>();
        List<Long> valCanMoveList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextLong();
            sumB += b[i];
            if (a[i] < b[i]) {
                notPassIdxList.add(i);
            } else {
                valCanMoveList.add(a[i] - b[i]);
            }
        }
        if (sumA < sumB) {
            System.out.println(-1);
            return;
        }
        Collections.sort(valCanMoveList, Collections.reverseOrder());
        int j = 0;
        long target = 0;
        for (int i = 0; i < notPassIdxList.size(); i++) {
            int k = notPassIdxList.get(i);
            while (target < b[k] - a[k]) {
                target += valCanMoveList.get(j++);
            }
            target -= b[k] - a[k];
        }
        System.out.println(n - (valCanMoveList.size() - j));
    }

}


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

// input
int Q;

ll n;
ll asum, bsum, midsum;
multiset<ll> s;
multiset<ll>::iterator itr;


void input() {
    cin >> Q;
}


void param_init() {
    int q, a, b;
    cin >> q >> a >> b;
    n = 1;
    asum = a;
    bsum = b;
    midsum = a;
    s.insert(a);
    itr = s.find(a);
}


void query1() {
    int a, b;
    cin >> a >> b;
    asum += a;
    bsum += b;
    s.insert(a);
    if (a < *itr) {
        midsum += a;
        if (n % 2 == 1) midsum -= *(itr--);
    } else {
        if (n % 2 == 0) midsum += *(++itr);
    }
    n++;
}


void query2() {
    ll x = *itr;
    ll fx = bsum;
    fx += (n + 1) / 2 * (*itr) - midsum;
    fx += (asum - midsum) - n / 2 * (*itr);
    printf("%ld %ld\n", x, fx);
}



int main() {
    input();
    param_init();
    rep(i, Q - 1) {
        int q;
        cin >> q;
        if (q == 1) query1();
        else query2();
    }
}


Measured memory_bytes: 9600
N = int(input())

List = []

for i in range(N):
    S_i,P_i = map(str, input().split() )
    temp_list = [i+1, S_i, int(P_i)]
    List.append(temp_list)

result = sorted(List,key=lambda x:x[2], reverse = True)
result = sorted(result,key=lambda x:x[1])

for j in range(N):
    print(str(result[j][0]))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 10005

int N;
int P[5005],F[5005];
vector<int> V;
int P_table[NUM],F_table[NUM];
int P_TMP[NUM],F_TMP[NUM];

int calc(){

	for(int i = 0; i < NUM; i++){

		P_TMP[i] = P_table[i];
		F_TMP[i] = F_table[i];
	}

	int P_num = 1,F_num = 2;
	int ret = 0;

	while(true){

		while(P_num < NUM && P_TMP[P_num] == 0)P_num++;
		while(F_num < NUM && (P_num >= F_num || F_TMP[F_num] == 0))F_num++;

		if(F_num == NUM)break;

		while(F_TMP[F_num] > 0 && P_TMP[P_num] > 0){
			F_TMP[F_num]--;
			P_TMP[P_num]--;
			ret++;
		}
	}

	return ret;
}

int main(){

	for(int i = 0; i < NUM; i++){

		P_table[i] = 0;
		F_table[i] = 0;
	}

	scanf("%d",&N);

	for(int i = 0; i < N; i++){

		scanf("%d",&P[i]);
		P_table[P[i]] += 1;
	}

	for(int i = 0; i < N; i++){

		scanf("%d",&F[i]);
		F_table[F[i]] += 1;
		V.push_back(F[i]);
	}

	int max_num = calc();

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

	queue<int> ANS;
	int num_larger = 0;
	int left,right,mid,this_value,tmp_larger,index;

	for(int i = 0; i < N; i++){

		this_value = -1;
		left = 0,right = V.size()-1,mid = (left+right)/2;

		while(left <= right){

			F_table[V[mid]] -= 1;
			P_table[P[i]] -= 1;

			tmp_larger = calc();

			F_table[V[mid]] += 1;
			P_table[P[i]] += 1;

			if(V[mid] <= P[i]){

				if(num_larger+tmp_larger == max_num){

					this_value = V[mid];
					index = mid;

					left = mid+1;
				}else{

					if(V[V.size()-1] <= P[i]){

						right = mid-1;

					}else{

						left = mid+1;
					}
				}

			}else{

				if(num_larger+tmp_larger+1 == max_num){

					this_value = V[mid];
					index = mid;
					left = mid+1;

				}else{

					right = mid-1;
				}
			}
			mid = (left+right)/2;
		}

		ANS.push(this_value);

		if(this_value > P[i]){

			num_larger++;
		}
		F_table[this_value] -= 1;
		P_table[P[i]] -= 1;
		V.erase(V.begin()+index);
	}

	printf("%d",ANS.front());
	ANS.pop();

	while(!ANS.empty()){

		printf(" %d",ANS.front());
		ANS.pop();
	}
	printf("\n");

	return 0;
}



Measured memory_bytes: 3528
#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 k;
    cin >> k;
    ll a = 0;
    int ans = 0;
    do
    {
        ans++;
        a *= 10;
        a += 7;
        a %= k;
        if (ans > k)
        {
            cout << -1 << endl;
            return 0;
        }
    } while (a != 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600