akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
int n,a[105];
int A,B;
int main()
{
	fast;
	cin>>n;
	for (int i=1;i<=n;i++)
	   cin>>a[i];
	sort(a+1,a+n+1); 
	for (int i=1;i<=n;i++)
	   if (i%2!=0)
	      A+=a[i];
	   else
	      B+=a[i];
	cout<<abs(A-B);
	return 0;
}

Measured memory_bytes: 384
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cctype>
using namespace std;

int main() {
	string W,T;
	int S=0;
	cin>>W;
	for (int i=0;i<W.size();i++){
		W[i]=toupper(W[i]);
	}

	while(1){
		cin>>T;
		if (T=="END_OF_TEXT")break;
		for (int j=0;j<T.size();j++){
			T[j]=toupper(T[j]);
		}
		if (W==T)S+=1;


	}


	cout<<S<<endl;
	return 0;
}

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

namespace atcoder.abc171.a
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Convert.ToChar(getStringParam()) > 'Z' ? 'a' : 'A');
        }

        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}


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

using namespace std;

int main() {
    int X, Y;
    cin >> X >> Y;

    string ans = "No";
    for(int i = 0; i < X + 1; i++) {
        int j = X - i;
        if(2 * i + 4 * j == Y) {
            ans = "Yes";
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  string s;
  cin>>s; 
  string snuke=s.substr(a-1,c-a+1);
  string hnuke=s.substr(b-1,d-b+1);
  string oikosi=s.substr(max(b-2,0),min(d,n-1)-max(b-2,0)+1);
  if(c<d){
    if(snuke.find("##")==std::string::npos
       && hnuke.find("##")==std::string::npos){
      cout<<"Yes";
    }else{
      cout<<"No";
    }
  }else{
    if(snuke.find("##")==std::string::npos
       && hnuke.find("##")==std::string::npos
       && oikosi.find("...")!=std::string::npos){
      cout<<"Yes";
    }else{
      cout<<"No";
    }
  }
}

Measured memory_bytes: 772
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
double R;
cin >> R;
cout << fixed<<setprecision(4)<<2 * R * 3.141592653<< endl;
//system("pause");
return 0;
}

Measured memory_bytes: 3804
N = int(input())
A = list(map(int, input().split()))
D = {}
for a in A:
    if a in D:
        D[a] += 1
    else:
        D[a] = 1
ans = 0
for a in set(A):
    if D[a] < a:
        ans += D[a]
    elif D[a] > a:
        ans += D[a] - a
print(ans)


Measured memory_bytes: 73384
#include <iostream>

using namespace std;

int main()
{
  int N, Q;
  int op, k;
  int index = 0;
  
  cin >> N >> Q;
  while (Q--) {
    cin >> op >> k;
    if (op == 0) {
      int element = (index + k) % N;
      element ? cout << element << endl : cout << N << endl;
    } else if (op == 1) {
      index = (index + k) % N;
    }
  }
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,t;
  t = 0;
  string s;
  cin >> N >> s;
  for(int i = 0; i <= N-1;i++)
  {
    if(s.at(i) == 'R')
    {
      t++;
    }
    else if(s.at(i) == 'B')
    {
      t--;
    }
  }
  if(t >0)
  {
    cout << "Yes";
  }
  else if(t <= 0)
  {
    cout << "No";
  }
}

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 scanner = new Scanner(System.in);

    int H = scanner.nextInt();
    int W = scanner.nextInt();
    int D = scanner.nextInt();

    List<Cell> cells = new ArrayList<>();
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        int a = scanner.nextInt();
        cells.add(new Cell(i, j, a));
      }
    }
    Collections.sort(cells);

    int[][] acc = new int[D][H * W / D + 1];
    for (int i = 0; i < D; i++) {
      int sum = 0;
      Cell prev = null;
      for (int j = i; j < cells.size(); j += D) {
        Cell c = cells.get(j);
        if (prev != null) sum += Math.abs(c.x - prev.x) + Math.abs(c.y - prev.y);
        acc[(i + 1) % D][j / D] = sum;
        prev = c;
      }
    }

    int Q = scanner.nextInt();
    for (int i = 0; i < Q; i++) {
      int l = scanner.nextInt();
      int r = scanner.nextInt();
      System.out.println(acc[r % D][(r - 1) / D] - acc[l % D][(l - 1) / D]);
    }
  }

  private static class Cell implements Comparable<Cell> {
    public final int x;
    public final int y;
    public final int num;

    private Cell(int x, int y, int num) {
      this.x = x;
      this.y = y;
      this.num = num;
    }

    @Override public int compareTo(Cell o) {
      return num - o.num;
    }
  }
}


Measured memory_bytes: 92756
import java.util.Scanner;

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();
		if((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


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

using namespace std;

typedef long long int ll;

int main(){
	int a,cnt5 = 0,cnt7 = 0;
	for(int i = 0; i < 3; i++){
		cin >> a;
		if(a == 5){
			cnt5++;
		}else if(a == 7){
			cnt7++;
		}
	}
	if(cnt5 == 2 && cnt7 == 1){
		cout << "YES";
	}else{
		cout << "NO";
	}	
}


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

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

    for (int i = 0; i < (int)S.length(); i++) {
        string rotS = S.substr(i) + S.substr(0, i);
        if (rotS == T) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string.h>
#include <utility>
#include <queue>
#include <stack>
#include <iomanip>
#include <ctype.h>
#include <map>
#include <set>
#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <sstream>
#include <math.h>
#include <time.h>
#include <iostream>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <tuple>
#include <cmath>
#include <stdio.h>      /* printf, fgets */
#include <stdlib.h>
#include <fstream>
#pragma comment(linker, "/STACK:67108864")

using namespace std;

typedef long long LL;

#define FOR(i,n) for(int i = 0;i < n;i++)
#define MP make_pair
#define PB push_back
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define CLEAR(a) memset(a, 0, sizeof(a))
#define ERASE(a) memset(a, -1, sizeof(a))
#define INF 2000000000
#define y1 uu1
#define y2 uu2
const double EPS = 1E-12;
const double PI = acos(-1.0);
const LL mod = 1000000007;

using namespace std;


int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  LL h,n,x;
  LL s =0;
  cin >>h>>n;
  FOR(i,n) {
    cin >> x;
    s+=x;
  }
  if(s>=h)cout<<"Yes"<<endl;else cout << "No"<<endl;
  return 0;
}


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

int main() {
    string A, B; cin >> A >> B;
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());
    while(A.size() || B.size()) {
        if(A.size()) cout << A.back(), A.pop_back();
        if(B.size()) cout << B.back(), B.pop_back();
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <map>
#include <set>
#include <list>
#include <stdio.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;
////////////////////////////
#define MOD (ll)(1e9+7)
#define OC(A,B,C) (C!=-1&&A+B<(C-A+N2)%N2+A)

int N,N2,K,A[666],B[666];
int mk[666];

int i,j,k;

ll f[666][666],g[666][666];
ll dp[666][666];

int main(){
    scanf("%d%d",&N,&K);
    N2=N*2;
    fornum(i,0,N2){
        mk[i]=-1;
    }
    fornum(i,0,K){
        scanf("%d%d",&A[i],&B[i]);
        mk[A[i]-1]=B[i]-1;
        mk[B[i]-1]=A[i]-1;
    }

    fornum(i,0,N2){
        f[i][i]=mk[i]==-1?1:0;
        fornum(j,i+1,N2+i){
            int J=j%N2;
            f[i][J]=f[i][(j-1)%N2];
            if(mk[J]==-1){
                f[i][J]++;
            }
            //printf("%lld ",f[i][J]);
        }
        //printf("\n");
    }

    fornum(i,0,N2){
        fornum(j,0,N2){
            
            int J=(i+j)%N2;
             if(f[i][J]%2){
                dp[i][J]=0;
                //printf("- ");
                continue;
            }
            fornum(k,0,j+1){
                if(OC(i,j,mk[(i+k)%N2])){
                    dp[i][J]=0;
                    //printf("- ");
                    J=-1;
                    break;
                }
            }
            if(J==-1)
                continue;
            
            
            
            g[i][J]=1;
            for(k=f[i][J]-1;k>0;k-=2){
                g[i][J]=(g[i][J]*k)%MOD;
            }
            dp[i][J]=g[i][J];
            //printf("%lld ",g[i][J]);
        }
        //printf("\n");
    }
    ll ans=0;
    fornum(i,0,N2){
        fornum(j,i,N2){
            //int J=(i+j)%N2;
            //printf("%lld ",g[i][J]);
            if(dp[i][j]==0)continue;
            fornum(k,i,j){
                //int K=(i+k)%N2;
                //printf("%lld:%lld ",dp[i][k],g[k+1][j]);
                dp[i][j]=(dp[i][j]+MOD-(dp[i][k]*g[k+1][j]%MOD))%MOD;
            }
            
            ans=(ans+dp[i][j]*(j-i!=N2-1?g[(j+1)%N2][(i+N2-1)%N2]:1))%MOD;
            //printf("%lld::%lld::%d,%d,%lld\n",dp[i][j],ans,i,j,g[(j+1)%N2][(i+N2-1)%N2]);
        }
    }
    /*
    fornum(i,0,N2-1){
        printf("%lld:%lld ",dp[0][i],g[i+1][N2-1]);
        dp[0][N2-1]=(dp[0][N2-1]+MOD-(dp[0][i]*g[i+1][N2-1]%MOD))%MOD;
    }
    */
    //ans=(ans+dp[0][N2-1])%MOD;
    printf("%lld\n",ans);
    return 0;
}





Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf=1e18L+5;
const int nax= 2e5+30;
vector<ll> dp(nax,0);
vector<ll> tree(4*nax);
vector<ll> lazy(4*nax);
void build(int v,int tl,int tr) 
{
    if(tl>tr) return;
    if(tl==tr)
    {
        tree[v]=dp[tl];
        return;
    }
    int tm=(tl+tr)/2;
    build(2*v,tl,tm);
    build(2*v+1,tm+1,tr);
    tree[v]=min(tree[2*v],tree[2*v+1]);
}
void push(int v)
{
    tree[2*v]+=lazy[v];
    tree[2*v+1]+=lazy[v];
    lazy[2*v]+=lazy[v];
    lazy[2*v+1]+=lazy[v];
    lazy[v]=0;
}
void add(int v,int tl,int tr,int l,int r,ll sum)
{
    int tm=(tl+tr)/2;
    if(l>r) return;
    if(tl>=l&&tr<=r)
    {
        lazy[v]+=sum;
        tree[v]+=sum;
        return;

    }
    else
    {
        push(v);
        add(2*v,tl,tm,l,min(tm,r),sum);
        add(2*v+1,tm+1,tr,max(l,tm+1),r,sum);
        tree[v]=min(tree[2*v],tree[2*v+1]);
    }
    

}
ll get_min(int v,int tl,int tr,int l,int r)
{
    if(l>r) return inf;
    if(tl>=l&&tr<=r)
    {
        return tree[v];
    }
    else
    {
        push(v);
        int tm=(tl+tr)/2;
        return(min(get_min(2*v,tl,tm,l,min(tm,r)),get_min(2*v+1,tm+1,tr,max(l,tm+1),r)));
    }
    
}
void update(int v,int tl,int tr,int pos,ll val)
{
    if(tl>tr) return;
    if(tl==tr)
    {
        tree[v]=val;
       // dp[tl]=val;
        return;
    }
    int tm=(tl+tr)/2;
     push(v);
    if(pos<=tm)
    {
       
        update(2*v,tl,tm,pos,val);
    }
    else update(2*v+1,tm+1,tr,pos,val);
    tree[v]=min(tree[2*v],tree[2*v+1]);
}
int main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<pair<int,ll>  > > vec(n+1);
    ll sum=0;
    for(int i=0;i<m;i++)
    {
        int l,r;ll a;
        cin>>l>>r>>a;
        sum+=a;
        vec[r].push_back({l,a});
    }
    dp[0]=0;
    build(1,0,n+1);
    for(int i=1;i<=n+1;i++)
    {
        for(auto it:vec[i-1])
        {
           // if(it.first>=1)
        //    if(it.first==1)
        //    {
        //        update(1,0,n+1,0,)
        //    }
            add(1,0,n+1,0,it.first-1,it.second);
            // for(int j=1;j<it.first;j++)
            // {
            //     dp[j]+=it.second;
            //     //dp[i]=max(dp[i],dp[j]+)
            // }
        }
        dp[i]=get_min(1,0,n+1,0,i-1);
       // add(1,0,n+1,i,i,(ll)(dp[i]-inf));
        update(1,0,n+1,i,dp[i]);



    }
    ll ans=sum-dp[n+1];
   // cout<<tree[0]<<endl;
   // for(auto it=0;it<=n+1;it++) cout<<dp[it]<<" ";
 //   cout<<endl;
    // for(int i=1;i<=n+1;i++)
    // {
    //     ans=min(ans,dp[i]);

    // }

    cout<<ans<<endl;

}

Measured memory_bytes: 25216
a, b= map(int, input().split())
if a % 2 ==0:
    start = a
    remain_before = 0
else:
    start = a+1
    remain_before = a

if b % 2 ==0:
    end = b-1
    remain_after = b
else:
    end = b
    remain_after = 0

if ((end+1-start) /2) %2 == 0:
    num = 0
else:
    num = 1

print(remain_before ^ num ^ remain_after)

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;

  s[k - 1] = tolower(s[k - 1]);
  cout << s << endl;
}

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

int main()
{
	int a, b, c, x, d = 0;
	cin >> a >> b >> c;
	d = 0;
	
	for(x = a; x <= b; x++)
	{
		if (c % x == 0)
			{
				d++;
			}
	}
	cout << d << endl;	
     return 0;
}

Measured memory_bytes: 3092
def C_hsi(N, M):
    x = 1900 * M + 100 * (N - M)  # 1回の提出に要する時間
    p_inv = 2**M  # 確率の逆数(除算を避けるため)
    ans = x * p_inv
    return ans

N,M = [int(_) for _ in input().split()]
print(C_hsi(N, M))

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

int main(){
  int N,K;
  cin >> N >> K;
  int x[N];
  for(int i=0;i<N;++i) cin >> x[i];
  int dist=min(abs(x[0])+x[K-1]-x[0],abs(x[K-1])+x[K-1]-x[0]);
  for(int i=1;i<N-K+1;++i){
    int d=min(abs(x[i])+x[K-1+i]-x[i],abs(x[K-1+i])+x[K-1+i]-x[i]);
    if(dist>d) dist=d;
  }
  cout << dist << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    int n = x/100;
    int m = x%100;
    
    if (m <= n*5) puts("1");
    else puts("0");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static int a, b, c;

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

    a = sc.nextInt();
    b = sc.nextInt();
    c = sc.nextInt();

    if(b - a == c - b){
      System.out.println("YES");
    }
    else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 22996
import sys 
try:
    sys.stdin = open('input.txt', 'r') 
    sys.stdout = open('output.txt', 'w')
except:
    pass

# input = sys.stdin.readline
d = {}
for _ in range(int(input())):
	s = input()
	d[s] = 1
print(len(d))
	



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    vector<int> v;
    int t = 0;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if(t != a) {
            v.pb(a);
        }
        t = a;
    }
    if(v.size() == 1) {
        cout << 1000 << endl;
        return 0;
    }

    vector<int> a;
    a.pb(v[0]);
    for(int i = 1; i < v.size() - 1; ++i) {
        if(v[i - 1] < v[i] && v[i] > v[i + 1] || v[i - 1] > v[i] && v[i] < v[i + 1]) {
            a.pb(v[i]);
        }
    }
    a.pb(v[v.size() - 1]);
    if(a.size() <= 1) {
        cout << 1000 << endl;
        return 0;
    }

    LL res = 1000;
    LL kab = 0;
    for(int i = 0; i < a.size() - 1; ++i) {
        if(a[i] < a[i + 1]) {
            kab += res / a[i];
            res = res % a[i];
        } else {
            res += kab * a[i];
            kab = 0;
        }
    }
    if(a[a.size() - 1] > a[a.size() - 2]) {
        res += kab * a[a.size() - 1];
    }

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



Measured memory_bytes: 3624
import sys
#input = sys.stdin.readline
def solve():
  n = int(input())
  d = list(int(i) for i in input().split())
  ans = 0
  for i in range(n):
    for j in range(n):
      if i != j:
        ans += d[i]*d[j]
  print(ans//2)
solve()

Measured memory_bytes: 2940
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;
typedef long long ll;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=100000+10;

int n,mx;
int a[N],s[N],S[N];

int c[N<<1];
inline int lowbit(int x) { return x&-x; }
inline void add(int x,int y) {
    for (;x<=mx;x+=lowbit(x)) c[x]+=y;
}
inline int query(int x) {
    int res=0;
    for (;x;x-=lowbit(x)) res+=c[x];
    return res;
}

inline int check(int mid) {
    memset(c,0,sizeof(c)),mx=0;
    for (re int i=1;i<=n;++i) {
        if (a[i]<mid) s[i]=-1;
        else s[i]=1;
    }
    ll res=0;
    for (re int i=1;i<=n;++i) s[i]+=s[i-1],res+=(s[i]>=0);
    for (re int i=1;i<=n;++i) s[i]+=n+1,mx=max(mx,s[i]);
    for (re int i=1;i<=n;++i) res+=query(s[i]),add(s[i],1);
    ll cnt=1ll*n*(n-1)/2+n;
    return cnt-res<cnt/2+1;
}

int main() {
    n=read();
    for (re int i=1;i<=n;++i) S[i]=a[i]=read();
    sort(S+1,S+n+1); int m=unique(S+1,S+n+1)-S-1;
    for (re int i=1;i<=n;++i) a[i]=lower_bound(S+1,S+m+1,a[i])-S;
    int L=1,R=m,ans=0;
    while (L<R) {
        int mid=(L+R+1)>>1;
        if (check(mid)) L=mid;
        else R=mid-1;
    }
    printf("%d\n",S[L]);
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int N, A, B, C, X;
    while(cin>>N>>A>>B>>C>>X, N|A|B|C|X){
        int f = 0;
        int y;
        for(int i=0; i<N; i++){
            cin >> y;
            while(X!=y && f<=10000){
                X = (A * X + B) % C;
                f++;
            }
            X = (A * X + B) % C;
            f++;
        }
        cout << (f>10001 ? -1 : f-1) << endl;
    }
    
    return 0;
}

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

string S;
char C[9] = { 'A', 'K', 'I', 'H', 'A', 'B', 'A', 'R', 'A' };

int cc[10][52];
int dp(int idx1, int idx2) {
    int &ret = cc[idx1][idx2];
    if(ret != -1) return ret;
    if(idx1 == 9 && idx2 == S.size()) return ret = 1;
    if(idx1 == 9) return ret = 0;

    ret = 0;
    if(C[idx1] == 'A') ret |= dp(idx1 + 1, idx2);
    if(idx2 < S.size() && C[idx1] == S[idx2]) ret |= dp(idx1 + 1, idx2 + 1);
    return ret;
}

int main() {
    cin >> S;

    memset(cc, -1, sizeof(cc));
    if(dp(0, 0)) printf("YES");
    else printf("NO");
}


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

int main() {
    long long n;
    std::cin >> n;
    for (auto i = 2ll; ; i++) {
        auto t = i * (i - 1) / 2;
        if (t > n) {
            std::cout << "No" << std::endl;
            return 0;
        } else if (t == n) {
            std::cout << "Yes" << std::endl;
            std::cout << i << std::endl;
            int c = 2 * n / i;
            std::vector<std::deque<std::pair<int, int>>> g(i);
            int cnt = 1;
            for (int j = 0; j < i; j++) {
                for (int k = j + 1; k < i; k++) {
                    g[j].push_back(std::make_pair(k, cnt));
                    g[k].push_back(std::make_pair(j, cnt));
                    cnt++;
                }
            }
            for (auto& el : g) {
                std::cout << c << " ";
                for (auto e : el) std::cout << e.second << " ";
                std::cout << std::endl;
            }
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3200
for _ in[0]*int(input()):
 X,z=input(),[]
 for y in input():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if not t:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 print(len(z))


Measured memory_bytes: 5616
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 50
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> new_data_set; 

ll ans[MAX][MAX];
ll a[MAX][MAX];
ll cache[MAX][MAX];

void twice(ll n){
	For(i,0,n) For(j,0,n) ans[i][j]=0;

	For(i,0,n){
		For(j,0,n){
			For(k,0,n){
				ll temp=(cache[i][k]*cache[k][j])%Mod;
				ans[i][j]=(ans[i][j]+temp)%Mod;
			}
		}
	}
	return;
}

void multiply(ll n){
	For(i,0,n) For(j,0,n) ans[i][j]=0;

	For(i,0,n){
		For(j,0,n){
			For(k,0,n){
				ll temp=(a[i][k]*cache[k][j])%Mod;
				ans[i][j]=(ans[i][j]+temp)%Mod;
			}
		}
	}
	return;
}

void asquare(ll n){
	For(i,0,n) For(j,0,n) ans[i][j]=0;

	For(i,0,n){
		For(j,0,n){
			For(k,0,n){
				ll temp=(a[i][k]*a[k][j])%Mod;
				ans[i][j]=(ans[i][j]+temp)%Mod;
			}
		}
	}

	return;
}

void power(ll n,ll k){
	if(k==1){
		For(i,0,n) For(j,0,n) cache[i][j]=a[i][j];
		return;
	}else if(k==2){
		asquare(n);
		For(i,0,n) For(j,0,n) cache[i][j]=ans[i][j];
		return;
	}

	power(n,k/2);
	twice(n);
	For(i,0,n) For(j,0,n) cache[i][j]=ans[i][j];
	if(k%2==0){
		
	}else{
		multiply(n);
		For(i,0,n) For(j,0,n) cache[i][j]=ans[i][j];
	}
	return;
}

int main(){
	ios_base::sync_with_stdio(false);

	ll n,k;cin>>n>>k;
	For(i,0,n) For(j,0,n) cin>>a[i][j];
	power(n,k);
	ll ans=0;
	For(i,0,n){
		For(j,0,n){
			ans = (ans+cache[i][j])%Mod;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
N,l=map(int,input().split())
apples=[]
apples_abs=[]
for n in range(1,N+1):
    apples.append(l+n-1)
    apples_abs.append(abs(l+n-1))
print(sum(apples)-apples[apples_abs.index(min(apples_abs))])


Measured memory_bytes: 2940
s = input()
l = 0
r = len(s)-1

x = 0
while l < r:
  if s[l] == s[r]:
    l+=1
    r-=1
  elif s[l] == "x":
    x += 1
    l += 1
  elif s[r] == "x":
    x += 1
    r -= 1
  else:
    print(-1)
    break
else:
  print(x)

Measured memory_bytes: 3316
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}


#include <iostream>

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

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

    if (S == "abc") { cout << "Yes" << endl; }
    else { cout << "No" << endl; }
}


Measured memory_bytes: 256
// segment tree (abstract version)

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

template<class M>
class segment_tree{
	int sz;
	vector<M> seg;
public:
	segment_tree(){}
	segment_tree(int n){ build(n); }
	segment_tree(const vector<M>& a){ build(a); }
	void build(int n){
		for(sz=1;sz<n;sz<<=1);
		seg.assign(2*sz,M());
	}
	void build(const vector<M>& a){
		int n=a.size();
		build(n);
		rep(i,n) seg[sz+i]=a[i];
		for(int i=sz-1;i>0;i--){
			seg[i]=seg[2*i]*seg[2*i+1];
		}
	}
	template<class N,class F>
	N query(int l,int r,const F& f){
		N lcum,rcum;
		for(int a=l+sz,b=r+sz;a<b;a>>=1,b>>=1){
			if(a&1) lcum=lcum*f(seg[a++]);
			if(b&1) rcum=f(seg[--b])*rcum;
		}
		return lcum*rcum;
	}
};

template<class T>
class sequence_monoid{
	vector<T> a;
public:
	sequence_monoid(){}
	sequence_monoid(const T& val):a(1,val){}
	sequence_monoid(const vector<T>& x):a(x){
		sort(a.begin(),a.end());
	}
	sequence_monoid operator*(const sequence_monoid& x)const{
		vector<T> res;
		merge(a.begin(),a.end(),x.a.begin(),x.a.end(),back_inserter(res));
		return res;
	}
	int lower_bound(const T& val)const{
		return std::lower_bound(a.begin(),a.end(),val)-a.begin();
	}
};

template<class T>
class add_monoid{
	T a;
public:
	add_monoid():a(){}
	add_monoid(const T& val):a(val){}
	add_monoid operator*(const add_monoid& x)const{
		return a+x.a;
	}
	T& get(){ return a; }
	const T& get()const{ return a; }
};

int main(){
	int n,q; scanf("%d%d",&n,&q);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]), a[i]--;

	vector<sequence_monoid<int>> x(n);
	vector<int> pre(n,-1);
	rep(i,n){
		x[i]=pre[a[i]];
		pre[a[i]]=i;
	}

	segment_tree<sequence_monoid<int>> S(x);
	rep(_,q){
		int l,r; scanf("%d%d",&l,&r); l--;
		auto ans=S.query<add_monoid<int>>(l,r,[&](const sequence_monoid<int>& x)->add_monoid<int>{
			return x.lower_bound(l);
		});
		printf("%d\n",ans.get());
	}

	return 0;
}


Measured memory_bytes: 125560
import java.util.Scanner;

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

    public Main() {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String[] s = new String[N];
        int[] t = new int[N];
        for (int i = 0; i < N; i++) {
            s[i] = sc.next();
            t[i] = Integer.parseInt(sc.next());
        }
        String X = sc.next();
        int xIndex = 0;
        for (int i = 0; i < N; i++) {
            if (X.equals(s[i])) {
                xIndex = i;
                break;
            }
        }
        int sum = 0;
        for (int i = xIndex + 1; i < N; i++) {
            sum += t[i];
        }
        System.out.println(sum);
    }
}


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

int main(){

  while(1){
    int n;
    int p[200];
    cin >> n;

    if(n == 0) break;
    int max = -1,min = 2000;
    for(int i = 0;i< n;i++){
      cin >> p[i];
      if(max < p[i])max = p[i];
      if(min > p[i])min = p[i];
    }

    int sum = 0,count=0;
    for(int i = 0;i< n;i++){
      if(max == p[i]){
	max = -1;
	continue;
      }
      if(min == p[i]){
	min = 2000;
	continue;
      }
      sum += p[i];
      count++;
    }

 
    cout << sum / count << endl;;

  }
  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>

int main() {
  using namespace std;

  int N;
  std::cin >> N;

  int h[100000];
  for (int i = 0; i < N; i++) {
    std::cin >> h[i];
  }

  int cost[100000];
  cost[0] = 0;
  cost[1] = abs(h[1] - h[0]);
  for (int i = 2; i < N; i++) {
    cost[i] = min(cost[i - 1] + abs(h[i] - h[i - 1]), cost[i - 2] + abs(h[i] - h[i - 2]));
  }

  cout << cost[N - 1] << std::endl;

  return 0;
}


Measured memory_bytes: 3948
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto ds = readln.split.to!(int[]);
    bool[24] T;
    T[0] = true;
    int solve(int i) {
        if (i == N) {
            int r = 12, j;
            foreach (k; 1..24) if (T[k]) {
                r = min(r, k - j, 24 - k + j);
                j = k;
            }
            r = min(r, 24 - j);
            return r;
        } else {
            if (ds[i] == 0) return 0;
            int j = ds[i], k = 24-ds[i], r1, r2;
            if (!T[j]) {
                T[j] = true;
                r1 = solve(i+1);
                T[j] = false;
            }
            if (!T[k]) {
                T[k] = true;
                r2 = solve(i+1);
                T[k] = false;
            }
            return max(r1, r2);
        }
    }
    writeln(solve(0));
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	long long N;
	scanf("%lld", &N);

	long long sum = 0;
	long long tmp = N;
	while(tmp>0){
		sum += tmp%10;
		tmp /= 10;
	}

	if(N%sum==0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int q = Integer.parseInt(br.readLine());
		for(int i = 0; i < q; i++){
			String[] tmpArray = br.readLine().split(" ");

			int px1 = Integer.parseInt(tmpArray[0]);
			int py1 = Integer.parseInt(tmpArray[1]);
			int px2 = Integer.parseInt(tmpArray[2]);
			int py2 = Integer.parseInt(tmpArray[3]);
			int px3 = Integer.parseInt(tmpArray[4]);
			int py3 = Integer.parseInt(tmpArray[5]);
			int px4 = Integer.parseInt(tmpArray[6]);
			int py4 = Integer.parseInt(tmpArray[7]);

			if(isParallel(px1, py1, px2, py2, px3, py3, px4, py4)){
				System.out.println(2);
			}
			else if(isOrthogonal(px1, py1, px2, py2, px3, py3, px4, py4)){
				System.out.println(1);
			}
			else{
				System.out.println(0);
			}
		}
	}

	static final double EPS = 0.0000001;

	static boolean isParallel(double px1, double py1, double px2, double py2, double px3, double py3, double px4, double py4){
		double vx1 = px2 - px1;
		double vy1 = py2 - py1;
		double vx2 = px4 - px3;
		double vy2 = py4 - py3;

		if(Math.abs(vx1*vx2) < EPS){
			if(Math.abs(vx1 + vx2) < EPS){
				return true;
			}
			else {
				return false;
			}
		}

		else if(Math.abs(vy1/vx1 - vy2/vx2) < EPS){
			return true;
		}
		else {
			return false;
		}

	}

	static boolean isOrthogonal(double px1, double py1, double px2, double py2, double px3, double py3, double px4, double py4){
		double vx1 = px2 - px1;
		double vy1 = py2 - py1;
		double vx2 = px4 - px3;
		double vy2 = py4 - py3;

		double innerProduct = vx1*vx2 + vy1*vy2;

		if(Math.abs(innerProduct) < EPS){
			return true;
		}
		else {
			return false;
		}
	}

}



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

int main() {
  int N;
  std::cin >> N;
  std::vector<int> counts(N + 1);
  for (int x = 1; x * x <= N; ++x) {
    for (int y = 1; y * y <= N; ++y) {
      for (int z = 1; z * z <= N; ++z) {
        const auto f = x * x + y * y + z * z + x * y + y * z + z * x;
        if (f <= N) {
          ++counts[f];
        }
      }
    }
  }
  for (int i = 1; i <= N; ++i) {
    std::cout << counts[i] << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
 int a,b;
 cin>>a>>b;
  if(a+b==15)
    out('+');
  else if(a*b==15)
    out('*');
  else
    out('x');
}


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

int main(void){
  int n, sub, x, y;
  int flag = 1;
  scanf("%d", &n);
  int array[n + 1][3];
  for(int i = 0; i < 3; i++){
    array[0][i] = 0;
  }
  for(int i = 1; i <= n; i++){
    scanf("%d %d %d", &array[i][0], &array[i][1], &array[i][2]);
  }
  
  for(int i = n; i > 0; i--){
    sub = array[i][0] - array[i - 1][0];
    x = array[i][1] - array[i - 1][1];
    if(x < 0) x = -x;
    y = array[i][2] - array[i - 1][2];
    if(y < 0) y = -y;
    if((sub % 2) != ((x + y) % 2) || (x + y) > sub){
      flag = 0;
      break;
    }
  }

  if(flag == 1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,a) for(int i=0;i<(a);i++)
#define MOD 1000000007

int N,M;
vector<vector<int>> G(100005);
bool used[100005];
vector<int> path;

void dfs(int s){
  path.push_back(s);
  used[s]=1;
  for(int i=0;i<G[s].size();i++){
    int t=G[s][i];
    if(!used[t]){
      return dfs(t);
    }
  }
}

int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0);
  reverse(path.begin(),path.end());
  path.pop_back();
  dfs(0);
  int n=path.size();
  cout<<n<<endl;
  for(int i=0;i<n-1;i++) cout<<path[i]+1<<" ";
  cout<<path[n-1]+1<<endl;
  return 0;
}


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

using namespace std;

int N;
vector<int> L(int n){
    vector<int> V(N*N);
    for(int i=0;i<N*N;i++) V[i]=i;
    for(int i=N*(n-1);i<N*n-1;i++){
        V[i]=i+1;
    }
    V[N*n-1]=N*(n-1);
    return V;
}

vector<int> R(int n){
    vector<int> V(N*N);
    for(int i=0;i<N*N;i++) V[i]=i;
    for(int i=N*(n-1)+1;i<N*n;i++){
        V[i]=i-1;
    }
    V[N*(n-1)]=N*n-1;
    return V;
}

vector<int> U(int n){
    vector<int> V(N*N);
    for(int i=0;i<N*N;i++) V[i]=i;
    for(int i=n-1;i+N<N*N;i+=N) V[i]+=N; 
    V[N*(N-1)+(n-1)]=n-1;
    return V;
}

vector<int> D(int n){
    vector<int> V(N*N);
    for(int i=0;i<N*N;i++) V[i]=i;
    for(int i=N+n-1;i<N*N;i+=N) V[i]-=N;
    V[n-1]=N*(N-1)+(n-1);
    return V;
}   

vector<int> C(vector<int> V1, vector<int> V2){
    vector<int> V(N*N);
    for(int i=0;i<N*N;i++) V[i]=V1[V2[i]];
    return V;
}

vector<int> T(vector<int> V ,int n){
    int b=1;
    vector<int> B=V;
    vector<int> ret(N*N);
    for(int i=0;i<N*N;i++) ret[i]=i;
    while(n>=b){
        if(b&n){
            ret=C(ret,B);
        }
        B=C(B,B);
        b<<=1;
    }
    return ret;
}

int number(string S, int& ite){
    int n=0;
    while('0'<=S[ite]&&S[ite]<='9'){
        n*=10;
        n+=S[ite]-'0';
        ite++;//??????????????§???')'???????°?
    }
    return n;
}

vector<int> rec(string S, int& ite){
    vector<int> ret(N*N),fac;
    for(int i=0;i<N*N;i++) ret[i]=i;
    while(ite<S.size()){
        if(S[ite]=='('){
            ite++;
            fac=rec(S,ite);
            ite++;//')'??????????£???°???
            fac=T(fac,number(S,ite));
            ret=C(ret,fac);
        }else{
            if(S[ite]=='R'){
                ite++;
                fac=R(number(S,ite));
            }else if(S[ite]=='L'){
                ite++;
                fac=L(number(S,ite));
            }else if(S[ite]=='D'){
                ite++;
                fac=D(number(S,ite));
            }else if(S[ite]=='U'){
                ite++;
                fac=U(number(S,ite));
            }else{
                cout<<"err"<<endl;
                exit(1);
            }
            ret=C(ret,fac);
        }
        if(S[ite]==')') break;
    }
    return ret;
}

int main(){
    int l;
    cin>>N>>l;
    string S;
    cin>>S;
    if(N==1){
        cout<<1<<endl;
        return 0;
    }
    int i=0;
    vector<int> ans = rec(S,i);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(j)cout<<' ';
            cout<<ans[i*N+j]+1;
        }
        cout<<endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define inin(a, n, i) memset(a, i, sizeof(a[0])*(n))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto& x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))
	
template<class T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }
template<class T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template<class A, class B> A cvt(B x) { stringstream s; s << x; A r; s >> r; return r; }

void read() {}
void print() {}
template<class T, class... Args> void read(T& a, Args&... args) { cin >> a; read(args...); }
template<class T, class... Args> void print(T a, Args... args) { cout << a << ' '; print(args...); }
template<class... Args> void println(Args... args) { print(args...); cout << '\n'; }

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

const int INF = 0x3F3F3F3F;
const int MAXN = (int) 1e6;
const int MOD = (int) 1e9+7;

//=========================

void run_test() {
	string n; read(n);
    int m = 0;
    rep(i, sz(n)) m = (m + n[i] - '0') % 9;
    println((m % 9 == 0 ? "Yes" : "No"));
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    ll N = SZ(S);
    ll a = 0, b = N-1;
    REP(i,0,N) {
        if(S[i] != 'A') ++a;
        else break;
    }
    REP(i,0,N) {
        if(S[N-i-1] != 'Z') --b;
        else break;
    }
    PR(b-a+1);

    return 0;
}

/*



*/

Measured memory_bytes: 3716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int N = Integer.parseInt(line);
		int[] a = new int[N+1];
		int count = 0;

		for(int i = 1; i <= N; i++) {
			line = sc.next();
			a[i] = Integer.parseInt(line);
		}

		for(int i = 1; i <= N; i++) {
			if(i % 2 == 1 && a[i] % 2 ==1) {
				count++;
			}
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 35676
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  ll n, ans = 0;
  cin >> n;
  for (ll i = 1; i < n; i++) {
    ans += n / i;
    if (n % i == 0) {
      ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
N = int(input())
total = 0
for i in range(1, N+1):
    if i % 3 == 0 and i % 5 == 0:
        FizzBuzz = i
    elif i % 3 == 0:
        Fizz = i
    elif i % 5 == 0:
        Buzz = i
    else:
        j = i
        total = total + j
print (total)

Measured memory_bytes: 9200
"""
NTC here
"""
import sys
inp = sys.stdin.readline


def input(): return inp().strip()


flush = sys.stdout.flush
# import threading
# sys.setrecursionlimit(10**6)
# threading.stack_size(2**25)


def iin(): return int(input())


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

# range = xrange
# input = raw_input


def main():
    def fn(s):
        l = len(s)
        l, r = 0, l-1
        while l<r:
            if s[l]!=s[r]:
                return False
            l+=1
            r-=1
        return True
    s = input()
    n = len(s)
    print("Yes" if fn(s) and fn(s[:n//2]) else "No")

main()
# threading.Thread(target=main).start()


Measured memory_bytes: 38384