akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <stdio.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

int main(){

    ll H, W, a, b;
    cin >> W >> H >> a >> b;

    ll area = H * W / 2;
    bool f1 = (b == (H / 2) );
    bool f2 = ( (H % 2) == 0);
    bool f3 = ( a == (W / 2) );
    bool f4 = ( (W % 2) == 0);
    if( f1 && f2 && f3 && f4 ){
        printf("%lld 1\n", area);
    }
    else if(f2 || f4){
        printf("%lld 0\n", area);
    }
    else{
        printf("%lld.5 0\n", area);
    }

}

Measured memory_bytes: 256
from itertools import product,combinations
N,K=map(int,input().split())
L=[tuple(map(int,input().split())) for i in range(N)]
ans=10**37
def f(i,j,k,l):
    n=0
    s=min(L[j][0],L[i][0])
    t=max(L[j][0],L[i][0])
    u=min(L[k][1],L[l][1])
    w=max(L[k][1],L[l][1])
    for e in L:
        if s<=e[0]<=t and u<=e[1]<=w:
            n+=1
    if n>=K:
        return (t-s)*(w-u)
    return 10**37
for i,j in combinations(range(N),2):
    for k,l in combinations(range(N),2):
        #print(i,j,k,l)
        ans=min(ans,f(i,j,k,l))
print(ans)

Measured memory_bytes: 79068
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		Random r = new Random();
		int N = sc.nextInt();
		long L = sc.nextLong();
		long T = sc.nextLong();
//		int N = r.nextInt(10);
//		long L = r.nextInt(100);
//		long T = r.nextInt(1000);
		int[] x = new int[N];
		boolean[] w = new boolean[N];
		ArrayList<Integer> cw = new ArrayList<>();
		ArrayList<Integer> ccw = new ArrayList<>();
		for(int i=0; i<N; i++) {
			x[i] = sc.nextInt();
			w[i] = sc.nextInt()==1;
//			x[i] = (i==0 ? 0 : x[i-1]) + r.nextInt(9) + 1;
//			w[i] = r.nextInt(2)==1;
			if(w[i])
				cw.add(x[i]);
			else
				ccw.add(x[i]);
		}
		Collections.reverse(cw);
		
		if(cw.size()==0 || ccw.size()==0) {
			for(int i=0; i<N; i++) {
				pw.println((x[i]+(w[i]? T%L : L-(T%L)))%L);
			}
		} else {
//			long t=0;
//			boolean dirCW = true;
//			int cwIdx=0;
//			int ccwIdx=(-1-Collections.binarySearch(ccw, cw.get(0)))%ccw.size();
//			int lane1 = -1, lane2 = -1;
//			boolean dir1=false;
//			boolean init = true;
//			while(t<2*L) {
//				if(init) {
//					t += (ccw.get(ccwIdx)-cw.get(cwIdx)+L) % L;
//					cwIdx++;
//					ccwIdx++;
//					init = false;
//				} else if(dirCW) {
//					int next = ccw.get(ccwIdx%ccw.size()) - ccw.get((ccwIdx-1)%ccw.size());
//					if(next<=0)
//						next += L;
//					t += next;
//					ccwIdx++;
//				} else {
//					int next = cw.get((cwIdx-1)%cw.size()) - cw.get(cwIdx%cw.size());
//					if(next<=0)
//						next += L;
//					t += next;
//					cwIdx++;
//				}
//				if(lane1==-1 && t>=2*(T%L)) {
//					lane1 = dirCW ? cw.get((cwIdx-1)%cw.size()) : ccw.get((ccwIdx-1)%ccw.size());
//					dir1 = dirCW;
//				}
//				if(lane2==-1 && t>=2*L) {
//					lane2 = dirCW ? cw.get((cwIdx-1)%cw.size()) : ccw.get((ccwIdx-1)%ccw.size());
//				}
//				dirCW ^= true;
//			}
//			int gap2 = Arrays.binarySearch(x, lane2) - Arrays.binarySearch(x, cw.get(0));
			
			int[] pos = new int[N];
			for(int i=0; i<N; i++)
				pos[i] = (int)((x[i]+(w[i]? T%L : L-(T%L)))%L);
			Arrays.sort(pos);
			
//			lane1 = (int)((lane1 + (dir1 ? T : L-(T%L)))%L);
//			int idx = Arrays.binarySearch(pos, lane1);
//			if(idx<N-1 && pos[idx]==pos[idx+1] && !dir1)
//				idx++;
////				idx = (idx-1+N)%N;
//			idx = (idx - Arrays.binarySearch(x, cw.get(0)) + N)%N;
//			idx = (int)((idx + ((long)gap2+N)*(T/L))%N);
			
			
			long cnt = 0;
			for(int ccwx : ccw) {
				long dis = (ccwx-cw.get(0)+L)%L;
				cnt = (cnt + (2*T + L-dis)/L)%N;
			}
			
			int cidx = (Arrays.binarySearch(pos, (int)((cw.get(0)+T)%L)) - Arrays.binarySearch(x, cw.get(0)) - (int)cnt + N + N)%N;
			
			for(int i=0; i<N; i++)
				pw.println(pos[(cidx+i)%N]);
//			if(cidx!=idx) {
//				pw.println("OK :"+cidx);
//				pw.println("NG :"+idx);
//			}
		}
		
		sc.close();
		pw.close();
	}
}


Measured memory_bytes: 91304
#include <stdio.h>
const int N=1e3+10;
void swap(int &a,int &b){
    int temp=a;
    a=b;
    b=temp;
    return ;
}
int main(){
    int n,t,a[N];
    while(true){
        scanf("%d",&n);
        if(n==0)return 0;
        t=0;
        for(int i=0;i<n;i++)scanf("%d",&a[i]);
        for(int i=0;i<n;i++)for(int j=0;j<n-1;j++){
            if(a[j]>a[j+1]){
                swap(a[j],a[j+1]);
                t++;
            }
        }
        printf("%d\n",t);
    }
}


Measured memory_bytes: 2724
#include"bits/stdc++.h"

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int N, K; cin >> N >> K;
	vector<int> p(N);
	rep(i, N)cin >> p[i];

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

	int ans = 0;
	rep(i, K)ans += p[i];

	cout << ans << endl;

	return 0;
}

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

int M,N;
int P[10000];
int C[10000],E[10000];
int dp[501][10001];

int min( int x,int y ){
	if( x < y )
		return x;
	return y;
}
int max( int x,int y ){
	if( x > y )
		return x;
	return y;
}

int compare( const void *s1,const void *s2 ){
	return *(int*)s2 - *(int*)s1;
}

int main(){
	int i,j;
	int ans = 0;
	int rui = 0;

	scanf("%d%d",&M,&N);
	for( i = 0;i < M;i++ )
		scanf("%d",P+i);
	for( i = 0;i < N;i++ )
		scanf("%d%d",C+i,E+i);

	for( i = 0;i <= N;i++ ){
		for( j = 0;j <= M;j++ ){
			dp[i][j] = 1000000000;
		}
	}

	dp[0][0] = 0;
	for( i = 0;i < N;i++ ){
		for( j = 0;j <= M;j++ ){
			dp[i+1][min(j+C[i],M)] = min( dp[i+1][min(j+C[i],M)],dp[i][j]+E[i] );
			dp[i+1][j] = min( dp[i+1][j],dp[i][j] );
		}
	}

	qsort(P,M,sizeof(int),compare);
	for( i = 0;i <= M;i++ ){
		ans = max( ans,rui-dp[N][i] );
		rui += P[i];
	}
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 20728
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
  
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<string> list = new List<string>();
            int dameflg = 0;
            for(int i = 0; i < N; i++)
            {
                list.Add(Console.ReadLine());
                if (i >= 1 && list[i].Substring(0 , 1) != list[i - 1].Substring(list[i-1].Length - 1 , 1))
                {
                    dameflg++;
                }
            }
            int baseCount = list.Count;
            int distinctCount = (from x in list select x).Distinct().Count();
            if (baseCount == distinctCount && dameflg == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13280
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys
# import numpy as np
# import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, *P = map(int, read().split())
print()
ans = 0
for i in range(N - 2):
    S = [P[i], P[i + 1], P[i + 2]]
    SS = sorted(S)
    if S[1] == SS[1]:
        ans += 1
print(ans)

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second

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

    int h, w, k;
    cin >> h >> w >> k;

    vector<vector<char>> v(h, vector<char>(w));

    for(int i = 0; i < h; ++i)
    {
        for(int j = 0; j < w; ++j)
        {
            cin >> v[i][j];
            //cout << v[i][j];
        }
    }

    int ans = 0;

    for(int i = 0; i < (1<<h); ++i)
    {
        for(int j = 0; j < (1<<w); ++j)
        {
            int temp = 0;
            for(int i2 = 0; i2 < h; ++i2)
            {
                for(int j2 = 0; j2 < w; ++j2)
                {
                    int p = (1<<i2), d = (1<<j2);
                    if(v[i2][j2] == '#')
                    {
                        int izraz1 = p&i,izraz2 = d&j;
                        if(izraz1 == 0 && izraz2 == 0)
                            ++temp;
                    }
                }
            }
            //cout << temp << '\n';
            ans += (temp == k);
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

s = s_in()

if s == 'ABC':
    print("ARC")
else:
    print("ABC")
    


Measured memory_bytes: 61664
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cmath>
#include <set>
using namespace std;



void solve()
{
	int n;
	cin >> n;

	for (int i = 1; i <= 9; i++)
	{
		if (n % i == 0)
		{
			int k = n / i;
			if (1 <= k && k <= 9)
			{
				cout << "Yes";
				return;
			}
		}
	}

	cout << "No";
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
s = input()
l = (len(s)-1)//2
rs = s[::-1]
if s[:l] == rs[:l]:
    l = len(s)//2
    ns1 = s[:l]
    ns2 = s[l+1:len(s)]
    if ns1 == ns1[::-1]:
        if ns2 == ns2[::-1]:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3060
#include<stdio.h>
#include<queue>
#include<math.h>
#include<time.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<map>
#include<stack>
#define LL long long
#define mem(a,b) memset(a,b,sizeof(a))
#define lowbit(a) a&(-a)
#define PI acos(-1)
#define shortime(a)  std::ios::sync_with_stdio(a);
using  namespace std;
const LL inf=16777216;
//long long cmp(node a,node b){ if(a.x==b.x) return a.r>b.r;return a.x>b.x;}
int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}
int judge(int x,int y,int z)
{
    if(x<y) return y;
    if(x>z) return z;
    return x;
}
int main()
{
    int x,k,a[100005];
    scanf("%d%d",&x,&k);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&a[i]);
    }
    int n,l=0,r=x,num=1;
    scanf("%d",&n);
    int flag=-1,sum=0;
    for(int i=0;i<n;i++)
    {
        int lr,t,a1;
        scanf("%d%d",&t,&a1);
        while(t>=a[num]&&num<=k)
        {
            lr=flag*(a[num]-a[num-1]);
            sum+=lr;
            l=judge(lr+l,0,x);
            r=judge(lr+r,0,x);
            num++;
            flag=-flag;
        }
        printf("%d\n",judge(flag*(t-a[num-1])+judge(a1+sum,l,r),0,x));
    }
    return 0;
}


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

int main(){
    int K,N,big=0;
    cin >> K >> N;
    int a[N],b[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
        if(i==N-1){
            b[i]=K-a[i];
            b[i]=b[i]+a[0];
        }
        if(i>0){
            b[i-1]=a[i]-a[i-1];
        }
    }
    for(int j=0;j<N;j++){
        if(b[big]<b[j]){
            big=j;
        }
    }
    cout << K-b[big] << endl;
}

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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)


int main(){
	int n,y;
	cin>>n>>y;
	y/=1000;
	REP(i,n+1){
		REP(j,n-i+1){
			if(i*10+j*5+(n-i-j)==y){
				cout<<i<<" "<<j<<" "<<n-i-j<<"\n";
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pip;
#define rep(i,j) for(int i=0;i<(j);i++)
#define pb(i) push_back(i)
#define fs first
#define sc second
int state[50][10];

int main(){
	int T,P,R;
	while(cin>>T>>P>>R&&T){
		fill_n(state[0],500,0);
		vector<pip> v;
		rep(i,T)v.pb(pip(0,pii(0,1+i)));
		int t,p,ti;
		string s;
		rep(i,R){
			cin >>t>>p>>ti>>s;
			t--;
			p--;
			if(s[0]=='C'){
				v[t].fs--;
				v[t].sc.fs += state[t][p]*1200+ti;
			}else{
				state[t][p]++;
			}
		}
		sort(v.begin(),v.end());
		rep(i,T){
			cout << v[i].sc.sc << " " << -v[i].fs << " " << v[i].sc.fs << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	string ans="";
	for(int i=0;i<s.size();i++){
		if(i+t.size()>s.size()){
			break;
		}
		string tmp=s;
		int cnt=0;
		for(int j=0;j<t.size();j++){
			if(s[i+j]==t[j]||s[i+j]=='?'){
				tmp[i+j]=t[j];
				cnt++;
			}
		}
		if(cnt==t.size()){
			for(int j=0;j<tmp.size();j++){
				if(tmp[j]=='?'){
					tmp[j]='a';
				}
			}
			if(ans==""){
				ans=tmp;
			}
			else{
				ans=min(ans,tmp);
			}
		}
	}
	if(ans==""){
		cout<<"UNRESTORABLE"<<endl;
	}
	else{
		cout<<ans<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[] = new int[n];
		for(int j = 0; j < n; j++){
			a[j] = scan.nextInt();
		}
		scan.close();
		InsertionSort(a, n);
	}

	static void InsertionSort(int A[], int N){
		print(A);
		for(int i = 1; i <= N - 1; i++){
			int v = A[i];
			int j = i - 1;
			while(j >= 0 && A[j] > v){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			print(A);
		}
	}

	static void print(int A[]){
		for(int k = 0; k < A.length; k++){
			if(k == A.length - 1){
				System.out.println(A[k]);
			}else{
				System.out.print(A[k] + " ");
			}
		}
	}
}

Measured memory_bytes: 33444
N = int(input())
T, A = list(map(int, input().split()))
H =list(map(int, input().split()))

conf =1000000000
cnt = 0
for i in H:
    if conf > abs(A -(T-i*0.006)):
        conf = abs(A -(T-i*0.006))
        cnt = i
        
print(H.index(cnt)+1)

Measured memory_bytes: 3064
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll monsts[100005];
ll atMosts[100005];

int main() {
	ll sum = 0;
	scanf("%lld", &N);
	for(int i = 0; i <= N; i++) {
		scanf("%lld", &monsts[i]);
		sum += monsts[i];
	}
	for(int i = 0; i < N; i++) {
		scanf("%lld", &atMosts[i]);
	}
	for(int i = 0; i < N; i++) {
		// sum += min(atMosts[i], monsts[i]);
		ll temp = atMosts[i];
		ll temp1 = monsts[i];
		atMosts[i] -= min(temp, temp1);
		monsts[i] -= min(temp, temp1);
		// sum += min(atMosts[i], monsts[i + 1]);
		temp = atMosts[i];
		temp1 = monsts[i + 1]; 
		atMosts[i] -= min(temp, temp1);
		monsts[i + 1] -= min(temp, temp1);
	}
	for(int i = 0; i <= N; i++) {
		sum -= monsts[i];
	}
	// cout << "\n";
	// for(int i = 0; i < N; i++) {
	// 	cout << atMosts[i] << " ";
	// }
	printf("%lld\n", sum);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

using namespace std;

int main() {

    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int  ans = 0;
    int MAX = N + 1;
    for (int i = 0; i <= N / R; ++i) {
        //int r = i * R;
        //if (r > N){ break;}
        for (int j = 0; j <= N/ G; ++j) {
          //  if (i * R + j * G > N ){break;}
            int balls = i * R + j * G;
            if ((N - balls) % B == 0 && (N - balls) / B >= 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

ll gcd(ll a,ll b){return b ? gcd(b,a%b) :a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}






ll di[]={1,0,-1,0};
ll dj[]={0,-1,0,1};

struct UnionFind {
    vector<int>d;
    UnionFind(int n=0):d(n,-1){}
    int find(int x){
        if((d[x])<0)return x;
        return d[x]=find(d[x]);
    }
    bool unite(int x,int y){
        x =find(x);y=find(y);
        if(x==y)return false;
        if(d[x]>d[y])swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    bool same(int x,int y){return find(x)==find(y);};
    int size(int x){return -d[find(x)];};
};

int deg[100005];
vector<int> to[100005];


ll n,m,q;
vector<ll>a,b,c,d;
ll ans;

void dfs(vector<ll> A){
    if(A.size()==n+1){
        ll sum=0;
        rep(i,q){
            if(A[b[i]]-A[a[i]]==c[i])sum+=d[i];
        }
        ans=max(ans,sum);
        return;
    }
    
    A.push_back(A.back());
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
}




int main()
{
 string ans;
 ll n;
 cin>>n;
 while(0<n){
  char a='a';
  n--;
  a+=n%26;
  ans+=a;
  n/=26;
 }
 reverse(ans.begin(),ans.end());
 cout<<ans<<endl;
}
 




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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var temp = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int n = temp[0];
            int m = temp[1];
            int n_sum = n * (n - 1) / 2;
            int m_sum = m * (m - 1) / 2;
            Console.WriteLine(n_sum + m_sum);
        }
    }
}


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

int main(){
    string s;
    cin >> s;
    vector<int> b;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'A'){
            b.pb(i);
            break;
        }
    }
    for(int i=s.size()-1;i>0;i--){
        if(s[i] == 'Z'){
            b.pb(i);
            break;
        }
    }
    cout << b[1] - b[0] + 1 << endl;
}

Measured memory_bytes: 640
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define sz(s) (int)(s.size())
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

bool ok(string s)
{
	int n = s.length();
	bool flag = true;
	fori(i, 0, n/2) if(s[i] != s[n-i-1]) flag = false;

	return flag;

}
     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);



    //start from here

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

    string s1 = s.substr(0, n/2);
    string s2 = s.substr(n/2+1, n/2);

    if(ok(s1) && ok(s2) && ok(s) == 1) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 256
# ABC138D

import sys
input=sys.stdin.readline
sys.setrecursionlimit(1000000000)

def dfs(adj,v,p,px,x,ct):
    x+=px[v]
    for nv in adj[v]:
        if nv==p:
            continue
        else:
            dfs(adj,nv,v,px,x,ct)
    ct[v]+=x

def main():
    N,Q=map(int,input().split())
    adj=[[] for i in range(N)]
    for i in range(N-1):
        a,b=map(int,input().split())
        adj[a-1]+=[b-1]
        adj[b-1]+=[a-1]
    px=[0]*N
    for i in range(Q):
        p,x=map(int,input().split())
        px[p-1]+=x
        
    ct=[0]*N
    dfs(adj,0,-1,px,0,ct)
    
    
    print(ct[0], end="")
    for i in range(1,N):
        print(" {}".format(ct[i]),end="")
    print("")
    
if __name__=="__main__":
    main()

Measured memory_bytes: 239860
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  if (a > b) {
    cout << 0 << endl;
    return 0;
  }
  if (n == 1) {
    cout << (a == b ? 1 : 0) << endl;
  } else {
    cout << 1LL * (n - 2) * (b - a) + 1 << endl;
  }
  return 0;	
}

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

using namespace std;
  
#define rep(i,n) for(int i=1;i<n;i++)  
  
long n,x;  
long a[50],p[50];  
  
long f(long n, long x){
 if(n==0){
   if(x>=1) return 1;
   else return 0;
 }
 else if(x<=1+a[n-1]) {
   return f(n-1,x-1);
 }
 else {
   return p[n-1]+1+f(n-1,x-2-a[n-1]);
 }

}  
  
  
int main(){
  cin >> n >> x;
  
  a[0]=1;
  p[0]=1;
  rep(i,n) {
    a[i]=2*a[i-1]+3;
    p[i]=2*p[i-1]+1;
  }
     
  cout << f(n,x) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, P; cin >> N >> P;
    int cnt[2] = {};
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        cnt[a%2]++;
    }
    if (P == 1 && cnt[1] == 0) {
        cout << 0 << endl;
    } else if (P == 1 && cnt[1] == 1) {
        cout << (1LL << cnt[0]) << endl;
    } else {
        cout << (1LL << (N - !!cnt[1])) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n,g = map(int, input().split())
standard = []
bonus = []
num_of_problems = []
for i in range(n):
    a,b = map(int, input().split())
    standard.append(a * (i+1) * 100)
    bonus.append(b)
    num_of_problems.append(a)
points_after_completion = []
min_num = 10 * 100
for i in range(2**n):
    point = 0
    num = 0
    li = list(range(n))
    for j in range(n):
        if (i >> j) & 1:
            point += standard[n-j-1] + bonus[n-j-1]
            num += num_of_problems[n-j-1]
            li.remove(n-j-1)
    counter = 0
    if li != []:
        while point < g and counter <= num_of_problems[li[-1]]:
            point += 100 * (li[-1]+1)
            num += 1
            counter += 1
    if num < min_num and point >= g:
        min_num = num
print(min_num)


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int numbers[] = new int[n];
		int min, max= 0;
		long sum=0;
		for (int i = 0; i < n; i++) {
			numbers[i] = sc.nextInt();
			sum += numbers[i];
		}
		min = numbers[0];
		max = numbers[0];

		for (int i = 1; i < n; i++) {
			if (min > numbers[i])
				min = numbers[i];

			if (max < numbers[i])
				max = numbers[i];
		}

		String output = min + " " + max + " " + sum;

		System.out.println(output);

	}

}

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

int main(){

    int a,b,c;

    cin >> a >> b >> c;

    int ma=max(a,max(b,c));

    if(ma==a){
        cout << b*c/2 << endl;
    }else if(ma==b){
        cout << a*c/2 << endl;
    }else{
        cout << b*a/2 << endl;
    }

    return 0;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


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

    string tmp = to_string(N);

    ll X = 0;

    rep(i,tmp.size()) X += (tmp[i]-'0');

    if( N%X == 0 ) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	int H,A; cin>>H>>A;
    ll ans = 0;
    while(H > 0) {
        H -= A;
        ans++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
/*input
3 3
abc


*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;

ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
vector<int> v;
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int K; cin >> K;
	
	int N = (1 << K);
	
	multiset<int> data;
	
	REP(i, N) {
		int cur; cin >> cur; data.insert(cur*-1);
	}
	
	vector<int> vals;
	vals.pb(*data.begin());
	data.erase(data.begin());
	
	REP(iteration, K) {
		vector<int> newVals;
		REP(i, sz(vals)) {
			if (data.upper_bound(vals[i]) == data.end()) {
				cout << "No" << endl; return 0;
			}
			newVals.pb(*(data.upper_bound(vals[i])));
			data.erase(data.upper_bound(vals[i]));
		}
		
		REP(i, sz(newVals)) {
			vals.pb(newVals[i]);
		}
		sort(ALL(vals));
	}
	cout<<"Yes";
}


Measured memory_bytes: 14208
import sys
input = sys.stdin.readline


def main():
    mod = 10**9+7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    x = 0
    for i in range(N-1):
        for j in range(i+1, N):
            if A[i] > A[j]:
                x += 1
    y = 0
    for i in range(N):
        for j in range(N):
            if A[i] > A[j]:
                y += 1
    ans = x * K + y * K * (K-1) // 2
    ans %= mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<iostream>
#include<math.h>

using namespace std;

int main() {

	int n;
	cin >> n;

	int count = 1;
	
	while (static_cast<double>(n) * pow(1.0 / 3, count) > 1.0) {
		++count;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>
   
   int main(void) {
       double A, B;
     
       scanf("%lf %lf" , &A, &B);

       if(A > B) {
          printf("GREATER\n");
       }else if(A < B){
          printf("LESS\n");
       }else if(A == B){
          printf("EQUAL\n");
       }
   return 0;
}

Measured memory_bytes: 128
#n = int(input())
#s = input()
#n, k= map(int,input().split())
#da = list(map(int,input().split()))
class UnionFind:
    def __init__(self, n):
        self.size = n
        self.par = [i for i in range(n)]
        self.rank = [0 for i in range(n)]
    def root(self, x):
        if self.par[x] != x:
            self.par[x] = self.root(self.par[x])
        return self.par[x]
    def unite(self, x, y):
        if self.root(x) == self.root(y):
            return
        if self.rank[x] > self.rank[y]:
            self.par[self.root(y)] = self.root(x)
        else:
            self.par[self.root(x)] = self.root(y)
        if self.rank[x] == self.rank[y]:
            self.rank[x]+=1
    def check(self, x, y):
        return self.root(x) == self.root(y)

n,m,k = map(int,input().split())
uf = UnionFind(n)
ans = [0 for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    uf.unite(a,b)
    ans[a]-=1
    ans[b]-=1
co = [0 for i in range(n)]
for i in range(n):
    co[uf.root(i)]+=1
for i in range(n):
    ans[i] += co[uf.root(i)]-1
for i in  range(k):
    c,d = map(int,input().split())
    if uf.check(c-1,d-1):
        ans[c-1]-=1
        ans[d-1]-=1
for i in range(n):
    if i == n-1:
        print(ans[i])
    else:
        print(ans[i],end=' ')

Measured memory_bytes: 10184
def main():
    n = int(input())
    alis = list(map(int, input().split()))
    blis = list(map(int, input().split()))
    clis = list(map(int, input().split()))
    ans = 0
    tmp = ""
    for a in alis:
        ans += blis[a-1]
        if tmp == a-1:
            ans += clis[a-2]
        tmp = a
    print(ans)
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 61912
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007

int main(){
   int n;
   ll ans=1;
   cin >> n;
   for(int i=1;i<=n;i++){
       ans*=i;
       ans%=mod;
   }
   cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  vector<int64_t> A;
  {
    int64_t NN;
    cin >> NN;
    // const int64_t L = static_cast<int64_t>(T.length());
    for (int64_t i = 0; i < NN; ++i) {
      int64_t a;
      cin >> a;
      if (i == 0) {
        A.emplace_back(a);
      } else if (a != A.back()) {
        A.emplace_back(a);
      }
    }
  }
  const int64_t N = static_cast<int64_t>(A.size());

  vector<int64_t> buy;
  // first buy
  buy.emplace_back(0);
  for (int64_t i = 1; i < N; ++i) {
    if (A[i] <= A[i - 1]) {
      buy[0] = i;
    } else {
      break;
    }
  }
  for (int64_t i = buy[0] + 1; i <= N - 2; ++i) {
    if (A[i] < A[i - 1] && A[i] < A[i + 1]) {
      buy.emplace_back(i);
    }
  }

  // last sell
  vector<int64_t> sell;
  sell.emplace_back(N - 1);
  for (int64_t i = N - 2; i >= 0; --i) {
    if (A[i] >= A[i + 1]) {
      sell[0] = i;
    } else {
      break;
    }
  }
  for (int64_t i = sell[0] - 1; i >= 1; --i) {
    if (A[i] > A[i - 1] && A[i] > A[i + 1]) {
      sell.emplace_back(i);
    }
  }
  reverse(sell.begin(), sell.end());

  int64_t result = 1000;
  int64_t cbuy = 0;
  int64_t csell = 0;
  while (sell[csell] <= buy[cbuy]) {
    ++csell;
  }
  while (cbuy < static_cast<int64_t>(buy.size()) &&
         csell < static_cast<int64_t>(sell.size())) {
    const int64_t stock = result / A[buy[cbuy]];
    result -= A[buy[cbuy]] * stock;
    result += A[sell[csell]] * stock;
    ++cbuy;
    ++csell;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3680
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

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

	int n; // [1, 9]
	cin >> n;
	// 3桁→n^3

	cout << (n * n * n) << endl; // prints !!!Hello World!!!
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
    char s[1005];
    scanf("%s",s);
    int len,a=0,b=0,c=0,d=0,i;
    len=strlen(s);
    for(i=0;i<len;i++)
    {
        if(s[i]=='N')a=1;
        else if(s[i]=='W')b=1;
         else if(s[i]=='S')c=1;
         else d=1;
    }
    if((a==1&&c==0)||(a==0&&c==1))
        printf("No\n");
    else if((b==1&&d==0)||(b==0&&d==1))
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <utility>

using namespace std;

int main() {

	int N, W;
	scanf("%d %d", &N, &W);
	pair<int, int> items[N];
	for (int i = 1; i <= N; ++i) {
		int v, w;
		scanf("%d %d", &v, &w);
		items[i] = make_pair(v, w);
	}

	int T[N + 1][W + 1];
	for (int i = 0; i <= N; ++i)
		T[i][0] = 0;
	for (int i = 0; i <= W; ++i)
		T[0][i] = 0;

	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (items[i].second <= j) {
				if (items[i].first + T[i - 1][j - items[i].second] > T[i - 1][j]) {
					T[i][j] = items[i].first + T[i - 1][j - items[i].second];
				} else {
					T[i][j] = T[i - 1][j];
				}
			} else {
				T[i][j] = T[i - 1][j];
			}
		}
	}
	int maxv = 0;
	for (int i = 1; i <= N; ++i) {
		maxv = max(maxv, T[i][W]);
	}

	cout << maxv << endl;

	return 0;
}

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

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    double v = a * a * b;
    if (x <= v / 2){
        double t = double(a * b * b) / (2 * x);
        cout << fixed << setprecision(10) << double(atan(t))/M_PI * 180 << endl;
    }
    else {
        double y = 2 * b * (1 - x / v);
        double t = y / a;
        cout << fixed << setprecision(10) << double(atan(t))/M_PI * 180 << endl;        
    }
}

Measured memory_bytes: 512
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)


def prime_factorize(n):
    p = []
    while n % 2 == 0:
        if 2 not in p:
            p.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if f not in p:
                p.append(f)
            n //= f
        else:
            f += 2
    if n != 1 and n not in p:
        p.append(n)
    return p


a, b = map(int, input().split())
q = prime_factorize(gcd(a, b))
# print(q)
print(len(q) + 1)


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

int main() {
    int x;
    int ans = 0;
    int band = 200;
    cin >> x;

    for (int i = 0; i < 8; i++) {
        int l = band * (i + 2);
        int r = l + band;
        if (l <= x && x < r) {
            ans = 8 - i;
            cout << ans << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){

  int N; cin >> N;

  vector <int> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];

  bool flag = true;

  for (int i = 0; i < N; i++){
    if (i != 0){
      if (H[i - 1] - H[i] > 0){
        flag = false;
        break;
      }else if (H[i - 1] != H[i]){
        H[i]--;
      }
    }else{
      H[i]--;
    }
  }

  if (flag == true) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
  return 0;
}


Measured memory_bytes: 640
n, k = gets.split.map(&:to_i)
W = n.times.map{gets.to_i}

N_MAX = K_MAX = 100000
W_MAX = 10000

l = 0
r = N_MAX * W_MAX

test = -> limit do
  i = 0
  0.step(k-1) do
    sum = 0
    while sum + W[i] <= limit
      sum += W[i]
      i += 1
      break if i == n
    end
    break if i == n
  end
  i+1
end

until (r - l) == 1 do
  m = (l + r) / 2
  v = test.(m)
  if v <= n
    l = m
  else
    r = m
  end
end

puts r


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

int main() {
    int n, y;
    cin >> n >> y;
    int a = -1, b = -1, c = -1;
    for(int i=0; i<=n; i++) {
        for (int j=0; i+j<=n; j++) {
            int k = n - i - j;
            int total = 10000 * i + 5000 * j + 1000 * k;
            if (total == y) {
                a = i;
                b = j;
                c = k;
            }
        }
    }
    
    
    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <utility>
#include <queue>
using namespace std;

typedef pair<int, int> pi;

int K;
deque<pair<int, int> > Q;
vector<bool> use;

int main(void) {
	cin >> K;

	use.resize(K, false);
	int ans;
	Q.push_back(make_pair(1, 1));

	while (!Q.empty()) {
		pi p = Q.front();
		Q.pop_front();
		if (p.first == 0) {
			ans = p.second;
			break;
		}
		if (use[p.first])
			continue;
		use[p.first] = true;
		int x = (p.first + 1) % K;
		int y = p.second;
		Q.push_back(make_pair(x, y + 1));
		x = (p.first * 10) % K;
		Q.push_front(make_pair(x, y));
	}

	cout << ans << '\n';
	return 0;
}


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

int main() {
    int a, b, i, num = 0;
    cin >> a >> b;

    for(i = a; i <= b; i++) {
        if(i % 10 == i / 10000 && (i % 100) / 10 == (i % 10000) / 1000)
            num++;
    }

    cout << num << endl;
}

Measured memory_bytes: 256
s=input()

result=[0]*(len(s)+1)


for index,ss in enumerate(s):
    if ss=="<":
        result[index+1]=result[index]+1
#print(result)
for i in range(len(s)):
    index=len(s)-i-1
    if s[index]==">":
        result[index]=max(result[index],result[index+1]+1)
print(sum(result))




#1 0 -1
#2 1 0
    




Measured memory_bytes: 46664
import sys
input=sys.stdin.readline  #危険！基本オフにしろ！


n,m,p=map(int,input().split())

d={}
for s in range(m):
    a,b,c=map(int,input().split())
    if a in d:
        d[a].append((b,c))
    else:
        d[a]=[(b,c)]

#print(d)


def BELLMANFORD(point,d,p):
    cost       = [-float("inf") for node in range(n+1)]  #infじゃないと閉路検出がうまくいかない
    cost[point]= 0
    for i in range(n-1):                                  #経路の長さは最大n-1であるため
        for now,lis in d.items():
            for nex,c in lis:
                if cost[nex]<cost[now]+c-p:
                    cost[nex]=cost[now]+c-p

    negative=[0]*n                                        #負閉路の長さは最大nであるため
    
    for i in range(n):                  #閉路判定 negativeの1は閉路に入っている部分を表す
        for now,lis in d.items():
            for nex,c in lis:
                if negative[now-1]==1:
                    negative[nex-1]=1
                if cost[nex]<cost[now]+c-p:
                    cost[nex]=cost[now]+c-p
                    negative[now-1]=1
 
    return cost,negative

def main():
    x,y=(BELLMANFORD(1,d,p))
    
    if y[n-1]==1:
        print(-1)
    else:
        print(max(x[n],0))

    
if __name__ == '__main__':
    main()

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

#define ll long long
#define ld long double
#define inf 100000000000000000
#define rep(i,a) for(ll i=0; i<a; ++i)
#define pb push_back

ll n;
ld x[20], y[20], a[20], A[35000], K[35000];
ld dp[35000];
ld mst[35000];

ll par[20];
ll getParent(ll p) {
  if (par[p]==-1) {
    return p;
  } else {
    par[p] = getParent(par[p]);
    return par[p];
  }
}
void setUnion(ll p, ll q) {
  if (getParent(p)==getParent(q)) {
    return;
  }
  par[getParent(p)] = getParent(q);
}

ld calDist(ll i, ll j) {
  return sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
}

ld calK(ll s) {
  ld ret=0;
  rep(i,n) {
    if (s&1==1) {
      ret++;
    }
    s = s>>1;
  }
  return ret;
}

ld calA(ll s) {
  ld ret = 0;
  rep(i,n) {
    if (s&1==1) {
      ret += a[n-i-1];
    }
    s = s>>1;
  }
  return ret;
}

ld calMst(ll s) {
  ld ret=0;
  rep(i,n) {
    par[i] = -1;
  }
  vector<ll> V;
  priority_queue<pair<ld, pair<ll,ll> > > heap; // (-dist, (i,j))
  rep(i,n) {
    if (s&1==1)
      V.pb(n-i-1);
    s = s>>1;
  }
  rep(i,V.size()) {
    rep(j,i) {
      heap.push(make_pair(-calDist(V[i],V[j]), make_pair(V[i], V[j])));
    }
  }
  while(!heap.empty()) {
    pair<ld, pair<ll,ll> > top = heap.top();
    ld w = -top.first;
    ll u = top.second.first;
    ll v = top.second.second;
    heap.pop();
    //cout<<"par: "<<par[0]<<" "<<par[1]<<" "<<par[2]<<endl;
    //cout<<"HI "<<heap.size()<<" "<<u<<" "<<v<<" "<<endl;
    //cout<<getParent(u)<<endl;
    if (getParent(u)!=getParent(v)) {
      ret += w;
      setUnion(u,v);
    }
  }
  return ret;
}

ld getDP(ll x) {
  if (dp[x]!=-1) {
    return dp[x];
  }
  //cout<<x<<endl;
  ld ret=0;
  rep(i,(1<<n)) {
    if ((i & x) == x && i!=x) {
      ll extra = i-x;
      ld sub = (A[extra]-mst[extra])/K[extra];
      ld rest = getDP(i);
      //cout<<x<<" calling "<<i<<" "<<sub<<" "<<rest<<" "<<A[extra]<<" "<<mst[extra]<<" "<<K[extra]<<endl;
      ret = max(ret, min(sub, rest));
    }
  }
  dp[x] = ret;
  return dp[x];
}

int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  rep(i,n) {
    cin>>x[i]>>y[i]>>a[i];
  }
  rep(i,(1<<n)) {
    mst[i] = calMst(i);
  }
  rep(i,(1<<n)) {
    K[i] = calK(i);
    //cout<<i<<" "<<K[i]<<endl;
  }
  rep(i,(1<<n)) {
    A[i] = calA(i);
  }
  //cout<<"over with mst, K, A"<<endl;

  rep(i,(1<<n)) {
    dp[i] = -1;
  }
  dp[(1<<n)-1] = inf;
  //cout<<getDP(32764)<<endl;
  cout<<fixed<<setprecision(11)<<getDP(0)<<endl;
  // rep(i,1<<n) {
  //   cout<<i<<" "<<getDP(i)<<endl;
  // }
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int N; cin >> N;
	vector<int> a(3 * N, 0);
	rep (i, 3 * N){
		cin >> a[i];
	} // end rep

	sort(ALL(a), greater<int>());

	ll res = 0LL;
	for (int i = 1; i < 2 * N; i += 2){
		res += (ll)a[i];
	} // end rep

	cout << res << endl;

	return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        // @DONE

        // Run a Floyd-Warshall or osmething
        Set<Integer> unvisited = new HashSet<>();

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer start = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(start.nextToken());
        int m = Integer.parseInt(start.nextToken());


        int[][] dist = new int[n][n];
        int[][] next = new int[n][n];

        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                dist[i][j] = Integer.MAX_VALUE/3;
                next[i][j] = -1;
            }
        }

        for(int j = 0; j < m; j++) {
            StringTokenizer path = new StringTokenizer(in.readLine());
            int begin = Integer.parseInt(path.nextToken()) - 1;
            int end = Integer.parseInt(path.nextToken()) - 1;
            int length = Integer.parseInt(path.nextToken());

            dist[begin][end] = length;
            dist[end][begin] = length;
            next[begin][end] = end;
            next[end][begin] = begin;
            unvisited.add(begin*n + end);
            unvisited.add(end*n + begin);
        }

        //System.out.println(unvisited);

        for(int i = 0; i < n; i++) {
            dist[i][i] = 0;
            next[i][i] = i;
        }


        for(int k = 0; k < n; k++) {
            for(int i = 0; i < n; i++) {
                for(int j = 0; j < n; j++) {
                    if(dist[i][j] > dist[i][k] + dist[k][j]) {
                        dist[i][j] = dist[i][k] + dist[k][j];
                        next[i][j] = next[i][k];
                    }
                }
            }
        }

        //System.out.println(Arrays.deepToString(dist));
        //System.out.println(Arrays.deepToString(next));

        for(int i = 0; i < n; i++) {
            for(int j = i + 1; j < n; j++) {
                if(next[i][j] != -1){
                    int a = i;
                    int b = j;
                    while(a != b) {
                        //System.out.println(a + " " + b + " " + next[a][b]);
                        int c = next[a][b];
                        unvisited.remove(a*n + c);
                        unvisited.remove(c*n + a);
                        a = c;
                    }
                }
            }
        }

        //System.out.println(unvisited);
        System.out.println(unvisited.size()/2);
    }
}


Measured memory_bytes: 25112
use proconio::input;
use std::collections::BTreeSet;
use std::ops::Bound::Included;

fn solve(n: usize, a: Vec<i32>) -> usize {
    let mut v = vec![BTreeSet::new(); n];
    for (i, x) in a.iter().enumerate() {
        let j = i as i32 - x;
        if j >= 0 {
            v[j as usize].insert(i);
        }
    }
    let mut ans = 0;
    for (i, x) in a.iter().enumerate() {
        let j = (i as i32 + x) as usize;
        if j < n {
            ans += v[j].len()
        }
    }
    ans
}

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }
    let r = solve(n, a);
    println!("{}", r);
}


Measured memory_bytes: 22064
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();

        double Cc = C * Math.PI /180;

        double L = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Cc));
        double h = b * Math.sin(Cc);
        double S = b * Math.sin(Cc) * a /2;

        System.out.println(S);
        System.out.println(L + a + b);
        System.out.println(h);
    }
}


Measured memory_bytes: 26248