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

long long NUMBER = pow(10,18);
long long A      = pow(10,9);
int main() {
  int n;
  cin >> n;
  
  vector<long long> numbers(n);

  for(int i=0; i<n;i++){
    cin >> numbers[i];
    if(numbers[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  
  long long sum = 1;
  for(int i=0; i<n;i++){
    if(sum > A && numbers[i] > A){
      cout << -1 << endl;
      return 0;
    }
    sum *= numbers[i];
    if(sum > NUMBER){
      cout << -1 << endl;
      return 0;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 4052
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define G() Cr=getchar()
int Xr;char Cr;
inline int rd(){
	Xr=0, G();
	while(Cr<'0'||Cr>'9')G();
	while(Cr>='0'&&Cr<='9')Xr=(Xr<<3)+(Xr<<1)+Cr-'0', G();
	return Xr;
}
int a,b,c;
int main(){
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int i,j,w,h,a[101][101][2];
while(scanf("%d%d",&w,&h),w+h){
h++;w++;
for(i=0;i<h;i++){
for(j=0;j<w;j++){
if(i==1||j==1){
a[i][j][0]=1;
a[i][j][1]=1;
}else{
a[i][j][0]=0;
a[i][j][1]=0;
}
}
}

for(i=2;i<h;i++){
for(j=2;j<w;j++){
a[i][j][0]=a[i-2][j][1]+a[i][j-2][0]+a[i-2][j-1][1];
a[i][j][1]=a[i-2][j][1]+a[i][j-2][0]+a[i-1][j-2][0];
a[i][j][0]%=100000;
a[i][j][1]%=100000;
}
}
h--;w--;
printf("%d\n",(a[h][w-1][0]+a[h-1][w][1])%100000);
}

return 0;}

Measured memory_bytes: 680
#include<iostream>
using namespace std;
int main()
{
    long a,b,c,d;
    long long int ans1,ans2,ans3,ans4,ans;
    cin>>a>>b>>c>>d;
    ans1=a*c;
    ans2=a*d;
    ans3=b*c;
    ans4=b*d;
    ans=max(ans1,ans2);
    ans=max(ans,ans3);
    ans=max(ans,ans4);
    cout<<ans<<endl;
}


Measured memory_bytes: 3672
N = int(input())
A = list(map(int,input().split()))

ans = [0]*N
for i in reversed(range(1,N+1)):
    v = A[i-1]
    for j in range(i,N+1,i):
        v += ans[j-1]
    ans[i-1] = v % 2

M = sum(ans)
print(M)
if M:
    print(*(i+1 for i,b in enumerate(ans) if b == 1))



Measured memory_bytes: 72080
package main

import (
	"fmt"
	"strconv"
	"log"
)

func main(){
	var a,b string
	fmt.Scan(&a, &b)
	t:=a+b
	x,e:=strconv.Atoi(t)
	if e !=nil{
		log.Fatal(e)
	}
	fmt.Print(foo(x))
}
func foo(x int)string{
	for n:=1;n*n<=100100;n++{
		if n * n ==x {
			return "Yes"
		}
	}
	return "No"
}

Measured memory_bytes: 512
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007


int N,K;
int A[200005];
int iscome[200005];
int machi[200005];
signed main(){
    scanf("%lld %lld",&N,&K);
    rep(i,N){
        scanf("%lld",&A[i]);A[i]--;
        iscome[i]=-1;
    }
    int now=0;
    int kaisu=0;
    while(iscome[now]<0){
        iscome[now]=kaisu;machi[kaisu]=now;
        now=A[now];
        kaisu++;
    }
    int ans=-1;
    if(K<kaisu)ans=machi[K];
    else{
        int syuuki=kaisu-iscome[now];
        int virtualK=(K-iscome[now])%syuuki+iscome[now];
        ans=machi[virtualK];
        //printf("%lld %lld",syuuki,virtualK);
    }
    printf("%lld\n",ans+1);
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

// Description: ????????????
// Verifyed: various problem 
const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
const P O=0.0L;
using L=struct{P s,t;};
using VP=vector<P>;
using C=struct{P p;R c;};

inline R dot(P o,P a,P b){return real(conj(a-o)*(b-o));}
inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline int sdot(P o,P a,P b){return sgn(dot(o,a,b));}
inline int sdet(P o,P a,P b){return sgn(det(o,a,b));}

//projection verify AOJ CGL_1_A
P proj(L l,P p){ R u=real((p-l.s)/(l.t-l.s)); return (1-u)*l.s+u*l.t;}

// vertical parallel
// verified: AOJ CGL_2_A
bool vertical(L a,L b) {return sdot(O,a.t-a.s,b.t-b.s)==0;}
bool parallel(L a,L b) {return sdet(O,a.t-a.s,b.t-b.s)==0;}
bool eql(L a,L b){ return parallel(a,b) and sdet(a.s,a.t,b.s)==0;}

// crossing determination
// verified: AOJ CGL_2_B 
bool iss(L a,L b){
	int sa=sdet(a.s,a.t,b.s)*sdet(a.s,a.t,b.t);
	int sb=sdet(b.s,b.t,a.s)*sdet(b.s,b.t,a.t);
	return max(sa,sb)<0;
}

// crossing point 
// verified: AOJ CGL_2_C
P cross(L a,L b){
	R u=det(a.s,b.s,b.t)/det(O,a.t-a.s,b.t-b.s);
	return (1-u)*a.s+u*a.t;
}
	
// distance 
// verified: AOJ CGL_2_D
R dsp(L l,P p){
	P h=proj(l,p);
	if(sdot(l.s,l.t,p)<=0) h=l.s;
	if(sdot(l.t,l.s,p)<=0) h=l.t;
	return abs(p-h);
}

R dss(L a,L b){return iss(a,b)?0:min({dsp(a,b.s),dsp(a,b.t),dsp(b,a.s),dsp(b,a.t)});}

istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}


int main(void){
	int n;
	cin >> n;
	cout.precision(20);
	rep(i,n){
		P a,b,c,d;
		cin >> a >> b >> c >> d;
		L s1={a,b},s2={c,d};
		P ans=cross(s1,s2);
		cout << fixed << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3220
from bisect import bisect_right

N = int(input())
S = [1]

for _ in range(N):
    a = int(input())
    a *= -1
    i = bisect_right(S, a)

    if i == len(S):
        S.append(a)
    else:
        S[i] = a

print(len(S))

Measured memory_bytes: 7068
n,m,l = map(int,input().split())
nm=[]
ml=[]
nl=[]

for i in range(n):
    nm1=input().split()
    nm1=[int(s) for s in nm1]
    nm.append(nm1)

for i in range(m):
    ml1=input().split()
    ml1=[int(s) for s in ml1]
    ml.append(ml1)


nl1=[]
s = 0

for i in range(n):
    for j in range(l):
        for k in range(m):
            s+=nm[i][k]*ml[k][j]
        nl1.append(s)
        s=0
    nl.append(nl1)
    nl1=[]

for i in range(n):
    print(*nl[i])



Measured memory_bytes: 7052
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var RGBN = Sarray();
            var R = RGBN[0];
            var G=RGBN[1];
            var B=RGBN[2];
            var N = RGBN[3];
            var ans = 0L;
            for (var i = 0; i <= N / R; ++i)
            {
                for (var j = 0; j <= N / G; ++j)
                {
                    var nokori = N - (i * R + j * G);
                    if (nokori < 0)
                        continue;
                    if (nokori % B == 0)
                        ++ans;
                }
            }
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  vector<vector<long long>> a(n, vector<long long>(n));
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin >> a[i][j];
  for(int i=0;i<n;i++) {
    for(int j=i+1;j<n;j++) {
      bool need = true;
      for(int k=0;k<n;k++) {
        if(k == i || k == j) continue;
        if(a[i][j] < a[i][k] + a[k][j]) continue;
        else if(a[i][j] == a[i][k] + a[k][j]) need = false;
        else {
          ans = -1;
          break;
        }
      }
      if(ans == -1) break;
      if(need) ans += a[i][j];
    }
    if(ans == -1) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
main(){
	string s;
	cin>>s;
	int ans = 1e9;
	for(int ch='a';ch<='z';ch++){		
		int maxDis = -1;
		int firstCh = -1;
		int lastCh  = -1;
		for(int i=0;i<s.length();i++){
			if(s[i]==ch){
				if(maxDis == -1){
					maxDis = 0;
					firstCh = i;									
				}	else	{
					maxDis = max(maxDis,i-lastCh-1);
				}				
				lastCh = i;
			}
		}		
		if(firstCh == -1){
			continue;
		}
		int lastDist = s.length()-1-lastCh;
		int maxThis = max(firstCh,lastDist);
		maxThis = max(maxThis,maxDis);
		ans = min(ans,maxThis);
	}
	cout << ans;
}

Measured memory_bytes: 256
W, H, X, Y = map(int, input().split())

# 長方形の対角線の交点を通る直線は長方形を2等分にするので交点を求める
a = W / 2
b = H / 2
area = W * H / 2
cnt = 0
if a == X and b == Y:
    cnt = 1

print(area,cnt)

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

int b[100003];

int main()
{
    int N;
    cin >> N;
    while (N--)
    {
        int t;
        cin >> t;
        b[t]++;
        b[t + 1]++;
        b[t + 2]++;
    }
    cout << *max_element(b + 2, b + 100000) << endl;
    return 0;
}

Measured memory_bytes: 3816
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	float a,b,c,d,e,f,x,y;
	while(cin>>a>>b>>c>>d>>e>>f){
	y=(c*d-a*f)/(b*d-e*a);
	x=(c-y*b)/a;
	printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod (int) (1e9+7)

void solve(){
  
  int a,b; cin>>a>>b;
  
  cout<<a*b<<"\n";
  
		return;
}

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


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

int main(){
  int r, c;
  cin >> r >> c;
  int A[101][101] = {};

  for ( int i = 0; i < r; i++ ){
    for ( int j = 0; j < c; j++ ){
      cin >> A[i][j];
    }
  }

  for ( int i = 0; i < r; i++ ){
    for ( int j = 0; j < c; j++ ){
      A[i][c] += A[i][j];
      A[r][j] += A[i][j];
      A[r][c] += A[i][j];
    }
  }

  for ( int i = 0; i <= r; i++ ){
    for ( int j = 0; j <= c; j++ ){
      cout << A[i][j];
      if ( j != c ) cout << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3136
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let k: usize = s.next().unwrap().parse().unwrap();
	let c: usize = s.next().unwrap().parse().unwrap();
	let s: Vec<_> = s.next().unwrap().chars().collect();
	let left = {
		let mut r = vec![0; n];
		let mut i = 0;
		let mut cnt = 1;
		while i < n {
			if s[i] == 'o' {
				r[i] = cnt;
				i += c + 1;
				cnt += 1;
			} else {
				i += 1;
			}
		}
		r
	};
	let right = {
		let mut r = vec![0; n];
		let mut cnt = k as i32;
		let mut i = 0;
		while i < n {
			if s[n - 1 - i] == 'o' {
				r[n - 1 - i] = cnt;
				i += c + 1;
				cnt -= 1;
			} else {
				i += 1;
			}
		}
		r
	};

	use std::io::Write;
	let out = std::io::stdout();
	let mut out = std::io::BufWriter::new(out.lock());
	for i in 0..n {
		if s[i] == 'x' {
			continue;
		}
		if left[i] == right[i] && left[i] > 0 {
			writeln!(out, "{}", i + 1).unwrap();
		}
	}
}


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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    char c;
    cin >> c;
    if ('a' <= c && c <= 'z') {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }
}

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

class Solution
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        long pattern = 0;
        long sum = 0;
        for (int i = 0, j = 0; i < n && j < n;)
        {
            while ((sum ^ a[j]) != (sum + a[j]))
            {
                sum ^= a[i];
                i++;
            }
            int x = j - i + 1;
            pattern += x;
            sum ^= a[j];
            j++;
        }

        Console.WriteLine(pattern);
    }
}

Measured memory_bytes: 34140
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll bg=pow(10,9)+7;
#define ff(i,n) for(i=0;i<n;i++)
#define gg1(n1) cin>>n1;
#define gg(n1,n2) cin>>n1>>n2;
#define gg3(n1,n2,n3) cin>>n1>>n2>>n3;
#define hh(n) cout<<n<<endl;
#define t top
#define p push
#define pb push_back
#define mp make_pair
ll arr[4000],x[4000][4000],y[4000][4000];
int main()
{
  ll i,j,n,k;
  cin>>n;
  for(i=0;i<n;i++)  
  {
         cin>>arr[i];
         x[0][i]=arr[i];
         y[0][i]=-arr[i];
  }
  for(i=1;i<n;i++)
  {
       for(j=0;j<n-i;j++)
       {
          x[i][j]=max(arr[j]+y[i-1][j+1],arr[j+i]+y[i-1][j]);  
          y[i][j]=min(-arr[j]+x[i-1][j+1],-arr[j+i]+x[i-1][j]);  
       }
  }

  cout<<x[n-1][0];
  return 0;
}

Measured memory_bytes: 188416
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll gsba(3), gsbb(3), a2b(3), b2a(3);
    for (int i = 0; i < 3; i++) cin >> gsba[i];
    for (int i = 0; i < 3; i++) cin >> gsbb[i];
    for (int i = 0; i < 3; i++) a2b[i] = gsbb[i] - gsba[i], b2a[i] = gsba[i] - gsbb[i];
    
    vvll dp(4, vll(n + 1, 0));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j <= n; j++) {
            chmax(dp[i + 1][j], dp[i][j]);
            if (j + gsba[i] <= n) chmax(dp[i + 1][j + gsba[i]], dp[i + 1][j] + a2b[i]);
        }
    }

    n += dp[3][n];

    dp = vvll(4, vll(n + 1, 0));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j <= n; j++) {
            chmax(dp[i + 1][j], dp[i][j]);
            if (j + gsbb[i] <= n) chmax(dp[i + 1][j + gsbb[i]], dp[i + 1][j] + b2a[i]);
        }
    }
    cout << n + dp[3][n] << '\n';
    return 0;
}


Measured memory_bytes: 979912
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(100002);
  for(int i=0;i<100002;i++){
    b[i]=0;
  }
  for(int i=0;i<n;i++){
    cin >> a[i];
    b[a[i]]++;
  }
  int m=0;
  for(int i=1;i<=100000;i++){
    if(m<b[i-1]+b[i]+b[i+1])m=b[i-1]+b[i]+b[i+1];
  }
  cout << m;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vvi E(210000);
vvi jisuu(210000);
ll dp[210000];
bool used[210000];
ll dfs(ll now){
  if(dp[now])return dp[now];
  if(E[now].size()==0)return 0;
  vi num;
  for(int i=0;i<E[now].size();i++){
    num.pb(dfs(E[now][i]));
  }
  ll plus=0;
  ll nnum=0;
  sort(ALL(num));
  for(int i=0;i<num.size();i++){
    if(i==0){
      nnum=num[i];
    }else{
      if(nnum>=num[i]){
	nnum++;
      }else{
	nnum=num[i];
      }
    }
   
  }
  return dp[now]=nnum+1;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  for(int i=2;i<=n;i++){
    ll a;cin>>a;
    E[a].pb(i);
  }
  dfs(1);
  cout<<dp[1]<<endl;
  return 0;
}


Measured memory_bytes: 24960
Main(myin());
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//不明値:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4);
  var output = 1;
  var updown = null;//増加:true 減少:false
  for(var i = 1; i < N; i++){
    if(updown == null){
       if(list[i-1] < list[i]){
          updown = false;
       }else if(list[i-1] > list[i]){
          updown = true;      
	   }
    }else{
      if(list[i-1] < list[i] && updown){
          updown = null;
        output++;
       }else if(list[i-1] > list[i] && !updown){
          updown = null;      
         output++;
	   }
    }
  }
  myout(output);
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    while (cin >> n)
    {
        int count = 0, p[n + 1] = {};
        for (int i = 2; i <= (int)sqrt(n); i++)
        {
            if (p[i] == 0)
            {
                for (int j = 2; i * j <= n; j++)
                {
                    p[i * j] = 1;
                }
            }
        }
        for (int i = 2; i <= n; i++)
        {
            if (p[i] == 0)
            {
                count++;
            }
        }
        OP(count)
    }

    return 0;
}


Measured memory_bytes: 7008
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n;cin >> n;
int temp = n;
int res = 0;
while(n >= 1){
res += n % 10;
n = n / 10;
}
  if(temp % res == 0){
      cout << "Yes " << endl;}
  else{
      cout << "No" << endl;}
  return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int n, k;
int w[100001];

bool check(int p)
{
    ll sum = 0;
    int idx = 0;

    rep(i, k){
        sum = 0;
        while(w[idx] + sum <= p){
            sum += w[idx];
            idx++;
            if(idx == n) return true;
        }
    }
    return false;
}

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

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

    // binary search
    ll left = 0; ll right = 100000*10000;
    while(right-left>1){
        ll mid = (left+right)/2;
        if(check(mid)) right = mid;
        else left = mid;
    }

    cout << right << endl;
}


Measured memory_bytes: 3480
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int>T(N),A(N),Tmax(N),Tmin(N),Amax(N),Amin(N);
    for(int i = 0;i < N;i++)cin >> T[i];
    for(int i = 0;i < N;i++)cin >> A[i];
    Tmax[0] = Tmin[0] = T[0];
    Amax[N-1] = Amin[N-1] = A[N-1];
    for(int i = 1;i < N;i++){
        if(T[i-1] < T[i]){
            Tmax[i] = Tmin[i] = T[i];
        }else{
            Tmax[i] = Tmax[i-1];
            Tmin[i] = 1;
        }
    }
    for(int i = N-2;i >= 0;i--){
        if(A[i] > A[i+1]){
            Amax[i] = Amin[i] = A[i];
        }else{
            Amax[i] = Amax[i+1];
            Amin[i] = 1;
        }
    }
    ll cnt = 1;
    for(int i = 0;i < N;i++){
        int lo = max(Tmin[i],Amin[i]);
        int hi = min(Tmax[i],Amax[i]);
        if(lo > hi){
            cnt = 0;
            break;
        }
        cnt = (cnt * ((hi-lo+1)%MOD)) % MOD;
    }
    cout << cnt << endl;
}   

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<sstream>
using namespace std;
int inf = 1000000000;

int main(){

  int a, b;
  cin >> a >> b;
  if( a%3==0||b%3==0||(a+b)%3==0 ) cout << "Possible" << endl;
  else cout << "Impossible" << endl;

  return 0;
}


Measured memory_bytes: 256
D,G = map(int,input().split())
p,c = [],[]
for i in range(D):
  tmp0 ,tmp1 = map(int,input().split())
  p.append(tmp0)
  c.append(tmp1)
  
min_ans = float('inf')

for bit in range(1<<D):
  dont_solved = [i for i in range(D)]
  ans = 0
  sum_point = 0
  for i in range(D):
    if bit & 1<<i:
      ans += p[i]
      sum_point += (i+1)*100*p[i]+c[i]
      dont_solved.remove(i)
  if sum_point < G:
    for i in  dont_solved[::-1]:
      for j in range(p[i]):
        ans += 1
        sum_point += (i+1)*100
        if sum_point >= G:
          break
      else:
        continue
      break
  
  if ans <= min_ans:
    min_ans = ans
print(min_ans)
  




Measured memory_bytes: 3064
N,Y = list(map(int,input().split()))

for x in range(0,N+1):
    for y in range(0,N+1-x):
        if (Y-x*10000-y*5000)%1000 == 0 and Y-x*10000-y*5000 >= 0:
            if x+y+(Y-x*10000-y*5000)//1000 == N:
                print(x,y,(Y-x*10000-y*5000)//1000)
                exit()
            
print(-1,-1,-1)

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

const int N = 305;
int cnt[4];
double dp[N][N][N];
int main()
{
    int n;
    scanf("%d", &n);
    REP(i, n)
    {
        int a;
        scanf("%d", &a);
        cnt[a]++;
    }

    double p = (double)1 / n;
    // dp[0][0][0]=1;
    REP(k, n + 1)
    {
        REP(j, n + 1)
        {
            REP(i, n + 1)
            {
                // current = current * (n-i-j-k)/n + (i, j+1, k-1) * k/n + (i+1, j-1, k) * (j/n) + (i-1, j, k)*(i/n) + 1
                double x = (n - i - j - k)*p;
                if(x < 0 || x == 1) continue;
                double res = 1;
                if (i)
                    res += dp[i - 1][j][k]*i*p;
                if (j)
                    res += dp[i + 1][j - 1][k]*j*p;
                if (k)
                    res += dp[i][j + 1][k - 1]*k*p;
                dp[i][j][k] = (res) / (1 - x);
            }
        }
    }
    printf("%.9lf\n", dp[cnt[1]][cnt[2]][cnt[3]]);
    return 0;
}

Measured memory_bytes: 219392
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ;
    cin >> n ;
    vector<int> v(n) ;
    for(int i = 0; i < n; i++){
        cin >> v[i] ;
    }
    int nix = v[0] ;
    int ans = 1;
    for(int i = 1; i < n; i++){
        if ( nix > v[i] ) ans++ ;
        nix = min(nix, v[i]) ;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 4784
#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);
	
	ll X, Y, Z; cin >> X >> Y >> Z;

	ll res = 0LL;
	ll low = 0LL;
	ll high = X;

	int iter = 0;
	while(low < high && iter < 30){
		ll mid = (low + high) / 2LL;
		if (mid * Y + Z * (mid + 1LL) <= X){
			res = mid;
			low = mid;
		}else{
			high = mid;
		} // end if
		++iter;
	} // end while
	
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

bool b[2005][2005];
int l[2005][2005];
int r[2005][2005];
int up[2005][2005];
int down[2005][2005];

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

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

    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j] == '.') {
                b[i][j] = true;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        int c = -1;
        for (int j = 0; j < w; j++) {
            if (b[i][j]) {
                l[i][j] = c;
            } else {
                c = j;
            }
        }

        c = w;
        for (int j = w-1; j >= 0; j--) {
            if (b[i][j]) {
                r[i][j] = c;
            } else {
                c = j;
            }
        }
    }

    for (int j = 0; j < w; j++) {
        int c = -1;
        for (int i = 0; i < h; i++) {
            if (b[i][j]) {
                up[i][j] = c;
            } else {
                c = i;
            }
        }

        c = h;
        for (int i = h-1; i >= 0; i--) {
            if (b[i][j]) {
                down[i][j] = c;
            } else {
                c = i;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (b[i][j]) {
                int tmp = r[i][j] - l[i][j] - 1;
                tmp += down[i][j] - up[i][j] - 1;
                tmp -= 1;
                ans = max(ans, tmp);
            }
        }
    }

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

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	double N;
	
	cin >> N;
	
	vector<double> x(N), y(N);
	
	rep(i, N)
		cin >> x[i] >> y[i];
		
	double ans = 0;
	
	rep(i, N)
		for(int j = i + 1; j < N; j++)
			ans += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
	
	printf("%f\n", 2 * ans / N);
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

class Program
{
    enum ABC
    {
        N = 0, A = 1, B = 2, C = 3
    }
    static int Getnn(List<ABC> value) { //Get not N
        int Result = 0;
        foreach (ABC v in value) {
            if (v != ABC.N) Result++;
        }
        return Result;
    }
    static bool isUsedAll(List<ABC> value) {
        bool[] used = new bool[3]; // ABC;
        foreach(ABC abc in value) {
            if (abc == ABC.A) used[0] = true;
            if (abc == ABC.B) used[1] = true;
            if (abc == ABC.C) used[2] = true;
        }
        return used[0] && used[1] && used[2];
    }



    static void DFS(int depth, List<ABC> value) {
        if (depth == list[0]) {
            if (isUsedAll(value) == false) return;
            int A = 0;
            int B = 0;
            int C = 0;
            int MP_tmp = (Getnn(value) - 3) * 10;
            for (int Count = 0; Count < list[0]; Count++) {
                if (value[Count] == ABC.A) A += l[Count];
                else if (value[Count] == ABC.B) B += l[Count];
                else if (value[Count] == ABC.C) C += l[Count];
            }
            MP_tmp += Math.Abs(list[1] - A);
            MP_tmp += Math.Abs(list[2] - B);
            MP_tmp += Math.Abs(list[3] - C);
            MPs.Add(MP_tmp);

            return;
        }

        for (int i = 0; i <= 3; i++) {
            List<ABC> clone = new List<ABC>(value);
            clone.Add((ABC)i);
            //WriteLine(depth);
            DFS(depth + 1, clone);
        }
    }

    static List<int> list = new List<int>();
    static List<int> l = new List<int>();
    static List<int> MPs = new List<int>();

    static void Main(string[] Args) {
        list = new List<string>(ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToList();
        l = new List<int>();
        for (int i = 0; i < list[0]; i++)
            l.Add(Int32.Parse(ReadLine()));

        List<ABC> vs = new List<ABC>();
        DFS(0, vs);

        WriteLine(MPs.Min());

        ReadLine();
    }
}

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

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

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

const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    dp[0] = 0;

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

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

    return 0;
}

Measured memory_bytes: 1792
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;

    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine();
            var ans = 0m;

            // bit列で全探索を行う
            for (int x = 0; x < Math.Pow(2, input.Length - 1); x++)
            {
                var array = new bool[input.Length - 1];

                // 右からk桁目を取り出す
                for (int k = 0; k < input.Length -1; k++)
                {
                    var y = (x >> k) & 1;
                    array[k] = y == 1;
                }
                var str = string.Empty;
                for (int i = 0; i < input.Length; i++)
                {
                    str += input[i] + (i != input.Length - 1 && array[i] == true ? "+" : "");
                }
                ans += str.Split('+').Select(p => long.Parse(p)).Sum();
            }

            Output(ans.ToString());
        }
        private static void Output(string str)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            Console.WriteLine(str);

            Console.Out.Flush();
        }

    }

Measured memory_bytes: 29172
n, y = map(int,input().split())
for i in range(n+1):
    for j in range(n+1):
        noguchi = (y - (10000 * i + 5000 * j))//1000
        if 0 <= noguchi and i+j+noguchi == n:
            print(i,j,noguchi)
            quit()

print(-1,-1,-1)

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  
  int n;
  cin >> n;
  
  const int m = 1e6 + 5;
  vector<int> cnt(m);
  vector<int> can(m);

  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    cnt[k]++;
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (cnt[i] == 1) {
      can[i] = 1;
    }
  }

  for (int i = 0; i < m; i++) {
    if (cnt[i]) {
      for (int j = i + i; j < m; j += i) {
        can[j] = 0;
      }
    }
  }

  for (int i = 0; i < m; i++) {
    ans += can[i];
  }

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


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

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

int arr[n+1];
for(int i=1;i<=n;i++)cin>>arr[i];

int count=0,maxi=-5,cnt=0;

maxi=arr[n];

for(int i=n-1;i>=1;i--)
{
    if(arr[i]>=maxi)
    {
        maxi=arr[i];count++;
    }
    else
    {
        maxi=arr[i];
        count=0;
    }
    if(count>cnt)cnt=count;
}

cout<<cnt<<endl;




return 0;
}


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

int gcd(int,int);

int main(){
  int x,y,dmax;

  scanf("%d %d",&x,&y);

  if(x < 1 || 1000000000 < x)exit(0);
  else if(y < 1 || 1000000000 < x)exit(1);

  dmax = gcd(x,y);

  printf("%d\n",dmax);

  return 0;
}

int gcd(int x, int y){
  int r,swap;

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

  return x;
}



Measured memory_bytes: 2144
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

void solve(){
    
    string S;

    cin >> S;

    if(S == "AAA" || S == "BBB")
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


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

long long segTree[300000] = {};
long long lazy[300000] = {};
int segSize = 1;

int n, q;

void init(){
  while(segSize < n) segSize *= 2;
  return;
}

void eval(int k, int l, int r){

  if(lazy[k] != 0){
    segTree[k] += lazy[k];

    if(r-l > 1){
      lazy[2*k+1] += lazy[k] / 2;
      lazy[2*k+2] += lazy[k] / 2;
    }

    lazy[k] = 0;
  }

  return;
}

void add(int a, int b, long long x, int k = 0, int l = 0, int r = -1){

  if(r == -1) r = segSize;

  eval(k,l,r);

  if(r <= a || b <= l) return;

  if(a <= l && r <= b){
    lazy[k] += (r-l) * x;
    eval(k,l,r);
  }else{
    add(a, b, x, 2*k+1, l, (l+r)/2);
    add(a, b, x, 2*k+2, (l+r)/2, r);
    segTree[k] = segTree[2*k+1] + segTree[2*k+2];
  }
  return;
}


long long getSum(int a, int b, int k = 0, int l = 0, int r = -1){
  if(r == -1) r = segSize;

  eval(k, l, r);

  if(r <= a || b <= l) return 0;
  if(a <= l && r <= b) return segTree[k];
  return getSum(a, b, 2*k+1, l, (l+r)/2) + getSum(a, b, 2*k+2, (l+r)/2, r);
}

int main(){
  cin >> n >> q;

  init();

  int p, a, b, c;
  for(int i = 0;i < q;i++){
    cin >> p;
    if(p == 0){
      cin >> a >> b >> c;
      a--; b--;
      add(a, b+1, c);
    }else{
      cin >> a >> b;
      a--; b--;
      cout << getSum(a, b+1) << endl;
    }
  }

  return 0;
}









Measured memory_bytes: 6268
const debug = (...args) => {
  process.env.NODE_ENV === "test" ? console.log(...args) : ""
}

const getACMap = (s) => {
  const acPoint = Array.from({ length: s.length + 1 }).map((i) => 0)
  let cnt = 0
  for (var i = 0; i < s.length; i = i + 1) {
    if (s[i] == "A" && s[i + 1] == "C") {
      cnt++
    }
    acPoint[i + 1] = cnt
  }
  return acPoint
}

const solve = (input) => {
  const [head, s, ...qLine] = input.split("\n")
  const qs = qLine.map((q) => q.split(" ").map(Number))
  const acMap = getACMap(s)
  debug(acMap)
  // debug(acMap)
  // const revAcMap = acMap.concat().reverse()

  const r = qs.map((q) => {
    const l = q[0] - 1
    const r = q[1] - 1
    return acMap[r] - acMap[l]
  })
  return r.join("\n")
}

if (process.env.NODE_ENV === "test") {
  module.exports = (input) => solve(input.trim())
} else {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(solve(input.trim()))
}


Measured memory_bytes: 54988
#include <iostream>

using namespace std;


int main()	{
  long long n;
  cin >> n;
  if (n <= 1)	{
    cout << n << endl;
    return 0;
  }
  long long i = 0;
  for (i = 1; i * i <= n; i++);
  cout << (i - 1) * (i - 1) << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;cin>>n>>k;
    vector<double> p(n);
    vector<double> w(n+1,0);
    for(int i=0;i<n;i++){
        cin>>p[i];
        w[i+1]=w[i]+p[i]*(p[i]+1)/(2.0*p[i]);
    }
    double ans=0.0;
    for(int i=k;i<n+1;i++){
        ans=max(w[i]-w[i-k],ans);
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
from sys import setrecursionlimit
setrecursionlimit(10000000)

N = int(input())
C = [[] for _ in range(N)]

for i in range(1, N):
    C[int(input())-1].append(i)

def cal(x):
    if len(C[x]) == 0:
        return 0
    else:
        D = sorted([cal(a) for a in C[x]], reverse=True)
        res = 0
        for i, d in enumerate(D, start=1):
            res = max(res, i+d)
        return res

print(cal(0))

Measured memory_bytes: 228024
import sys

def input() -> str:
    return sys.stdin.readline().rstrip()

h, n = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]
m = max(a for a, _ in ab)
dp = [0] * (h + m * 2 + 1)
for i in range(-m, h + m + 1):
    if i <= 0:
        dp[i] = 0
    else:
        dp[i] = min(dp[i - a] + b for a, b in ab)
print(min(dp[h:h + m + 1]))

Measured memory_bytes: 44252
#include <stdio.h>
#include <string.h>

//A 65  Z 90
int main(void) {
	int n;
	char s[10001];

	scanf("%d", &n);
	scanf("%s", s);

	for (int i = 0; i < strlen(s); ++i) {

		if (s[i] + n <= 90) {
			printf("%c", s[i]+n);
		}
		else {
			printf("%c", 64+s[i]+n-90);
		}
	}


	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
min_c = 1
max_c = n
for i in range(m):
    l, r = map(int, input().split())
    if l > min_c:
        min_c = l
    if r < max_c:
        max_c = r
if max_c >= min_c:
    print(max_c-min_c+1)
else:
    print(0)

Measured memory_bytes: 3060
import bisect
N, H = map(int, input().split())
B = [0] * N
m = 0
for i in range(N):
  a, b = list(map(int, input().split()))
  B[i] = b
  m = max(m, a)
  
B = sorted(B)
index = bisect.bisect_left(B, m)
#print(index)

over = sum(B[index:])
if over >= H:
  #Bのみ
  now = 0
  i = 1
  while now < H:
    now += B[-i]
    i += 1
  print(i - 1)  
else:
  H -= over
  ans = N - index
  ans += int(H / m)
  if H % m != 0:
    ans += 1
  print(ans)
  
  
  

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

using namespace std;

const long long int MOD = 1e9 + 7;
long long int f[200001];
long long int invf[200001];
long long int mypow(long long int a,long long int n)
{
	long long int res = 1;
	while(n>0)
	{
		if(n%2==1)
		{
			res = ((res%MOD)*(a%MOD)%MOD);
			res%=MOD;
		}
		a = ((a%MOD)*(a%MOD)%MOD);
		a%=MOD;
		n/=2;
	}
	return res;
}

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

	int n,k;
	long long int t;
	vector <long long int> v;

	cin >> n >> k;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
	}

	long long int res = 0;

	f[0] = 1;
	for(int i=1;i<=200000;i++)
	{
		f[i] = ((f[i-1]%MOD)*(i%MOD)%MOD);
		f[i]%=MOD;
	}
	invf[200000] = mypow(f[200000],MOD-2);
	for(int i=200000;i>0;i--)
	{
		invf[i-1] = ((i%MOD)*(invf[i]%MOD)%MOD);
		invf[i-1]%=MOD;
	}

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

	for(int i=k-1;i<n;i++)
	{
		long long int comb  = (f[i]%MOD)%MOD;
		comb = ((comb%MOD)*(invf[k-1]%MOD)%MOD);
		comb%=MOD;
		comb = ((comb%MOD)*(invf[i-k+1]%MOD)%MOD)%MOD;
		comb%=MOD;
		res = ((res%MOD)+((v[i]%MOD)*(comb%MOD)%MOD)%MOD);
		res%=MOD;
	}

	long long int res2 = 0;

	sort(v.rbegin(),v.rend());

	for(int i=k-1;i<n;i++)
	{
		long long int comb  = (f[i]%MOD)%MOD;
		comb = ((comb%MOD)*(invf[k-1]%MOD)%MOD);
		comb%=MOD;
		comb = ((comb%MOD)*(invf[i-k+1]%MOD)%MOD)%MOD;
		comb%=MOD;
		res2 = ((res2%MOD)+((v[i]%MOD)*(comb%MOD)%MOD)%MOD);
		res2%=MOD;
	}	
	
	res = ((res%MOD)-(res2%MOD)%MOD)%MOD;
	if(res<0)
	{
		res+=MOD;
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 4340
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    int N;
    string S;
    cin >> N >> S;
    for (int i = 0; i < S.length(); i++) {
        char cand = S[i] + N;
        if (S[i] + N > 'Z') {
            S[i] = 'A' + (cand - 'Z') - 1;
        } else {
            S[i] = cand;
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = []
b = list(map(int, input().split()))
for i in range(N, 0, -1):
    for j in range(i-1, -1, -1):
        if b[j] == j+1:
            a.append(b.pop(j))
            break
    else:
        a = [-1]
        break
for i in a[::-1]:
    print(i)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mk make_pair
#define fi first
#define lb lower_bound
#define test ll int t;cin>>t;while(t)
#define se second
using namespace std;

int main(){
   int n;
   cin>>n;
   vector<ll>arr(n);
   for(int i=0;i<n;i++){
       cin>>arr[i];
   }
   ll ans=0;
   for(int i=0;i<arr.size();i++){
       int j=i+1;
       while(j<n&&arr[i]>=arr[j]){
           ans+=arr[i]-arr[j];
           j++;
       }
       i=j-1;
   }
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4836
#include<stdio.h>
#include<iostream>
#include <iomanip>

using namespace std;

int main(){
  string s;
  cin>>s;
  
  int n=s.length();
  
  string s1,s2;
  s1=s.substr(0,n/2);
  s2=s.substr((n+3)/2-1,n);
    
  string ans="Yes";
  for(int i=0;i<(n-1)/2;i++){
    if(s[i]!=s[n-1-i]){
      ans="No";
      break;
    }
  }
  
  int n1=s1.length();
  int n2=s2.length();
  for(int i=0;i<n1;i++){
    if(s1[i]!=s1[n1-1-i] || s2[i]!=s2[n1-1-i]){
      ans="No";
      break;
    }
  }
  
  cout<<ans;
  
  return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int l = a + b;
    int r = c + d;

    if (l == r) {
        cout << "Balanced";
    } else if (l < r) {
        cout << "Right";
    } else {
        cout << "Left";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100

void prim(void);

int n,a[N][N];

int main(){
  int i,j,x;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      scanf("%d",&x);
      if(x == -1) a[i][j] = 10000000;
      else a[i][j] = x;
    }
  }

  prim();
  
  
  return 0;
}

void prim(void){
  int i,u,v,d[N],sum = 0,pi[N],mincost,color[N];
  
  for(u = 0;u < n;u++){
    d[u] = 10000000;
    pi[u] = -1;
    color[u] = 0; //0=white
  }

  d[0] = 0;

  while(1){
    mincost = 10000000;
    u = -1;
    for(i = 0;i < n;i++){
      if(color[i] != 2 && d[i] < mincost){ //2=black
	mincost = d[i];
	u = i;
      }
    }
    //if(mincost == 10000000) break;
    if(u == -1) break;

    color[u] = 2;

    for(v = 0;v < n;v++){
      if(color[v] != 2 && a[u][v] != 10000000){
	if(d[v] > a[u][v]){
	  pi[v] = u;
	  d[v] = a[u][v];
	  color[v] = 1; //1=gray
	}
      }
    }
  }

  for(i = 0;i < n;i++){
    if(pi[i] != -1) sum += a[i][pi[i]];
  }

  printf("%d\n",sum);

}



Measured memory_bytes: 2040
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        s: Chars,
    }

    for i in 0..s.len() {
        if s[i]==',' {
            print!(" ");
        } else {
            print!("{}", s[i]);
        }
    }
    print!("\n");
}


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

A = [list(map(int, input().split())) for _ in range(N)]

ans = sum(sum(a) for a in A) // 2
removeable = set()

for k in range(N):
    for i in range(N):
        for j in range(N):
            d = A[i][k] + A[k][j]
            if A[i][j] > d:
                print(-1)
                exit()
            if A[i][j] == d and i != k and j != k:
                removeable.add((i, j))

for i in range(N):
    for j in range(i + 1, N):
        if (i, j) in removeable:
            ans -= A[i][j]

print(ans)


Measured memory_bytes: 54108
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int a, b, c, x, y;

  cin >> a >> b >> c >> x >> y;

  int min_price = x * a + b * y;
  rep(a_num, x + 1) {
    int min_c_num = max((x - a_num) * 2, 0);

    int price_with_b = a_num * a + max((y - min_c_num / 2), 0) * b + min_c_num * c;
    int price_without_b = a_num * a + max(min_c_num, y * 2) * c;

    int price = min(price_with_b, price_without_b);
    if(price == 110000000) {

    }

    min_price = min(min_price, price);
  }

  cout << min_price << endl;
}

Measured memory_bytes: 3648
N, M = map( int, input().split() )
X = list( map( int, input().split() ) )

X.sort()
Xdif = []

for i in range(M-1):
    if i != M-1: Xdif.append( X[i+1]-X[i] )
Xdif.sort(reverse=True)

if N >= M: print(0)
else:
    ans = max(X) - min(X) # = X[M-1] - X[0]
    for i in range(N-1):
        ans -= Xdif[i]
    print(ans)

Measured memory_bytes: 13968
import java.util.*

fun main(args: Array<String>) {
    val scanner=Scanner(System.`in`)
    val n=scanner.nextLong()
    val Ak=ArrayList<Long>()
    (1..n).forEach { Ak.add(scanner.nextLong()) }
//    println(Ak)
     val kisuu= Ak.filter { it%2L==1L }.size
    if(kisuu%2==0){
        println("YES")
    }else{
        println("NO")
    }
}

Measured memory_bytes: 40772