akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    bool nonprime[1<<15] = {};
    nonprime[0] = nonprime[1] = true;

    for(int i = 2; i < 1<<15; i++){
        if(nonprime[i]) continue;
        for(int j = i+i; j < 1<<15; j+=i)   nonprime[j] = true;
    }

    int n;
    while(cin >> n, n){
        int cnt = 0;
        for(int i = 2; i+i <= n; i++){
            if(!nonprime[i] && !nonprime[n-i])  cnt++;
        }
        cout << cnt << endl;
    }
    
    return 0;
}


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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;

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

    int n,m;
    cin>>n>>m;
    vector<ll> a(n);
    for(auto &b : a ) cin>>b,b/=2;
    ll lcm = a[0];
    for(int i=1;i<n;++i){
        int gc = __gcd(lcm,a[i]);
        lcm = lcm * a[i]/gc;
    }
    bool ok = true;
    for(int i=0;i<n;++i){
        if((lcm/a[i])%2 == 0)ok = false; 
    }
    if(lcm > m or !ok){
        cout << 0 << endl;
        return 0;
    }
    cout << (m/lcm+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <list>

using namespace std;

int main() {
    list<int> l;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if ((i & 1) == 0) {
            l.push_back(a);
        } else {
            l.push_front(a);
        }
    }
    if ((n & 1) == 1) {
        l.reverse();
    }
    int i = 0;
    for (list<int>::const_iterator it = l.begin(); it != l.end(); it++) {
        cout << *it;
        if (i < n - 1) cout << ' ';
        i++;
    }
    cout << endl;
}


Measured memory_bytes: 8448
#include<stdio.h>
int main(void){
  int sum=700;
  char s[4]={'\0'};
  scanf("%s",s);
  for(int i=0;i<3;i++){
    if(s[i]=='o'){
      sum+=100;
    }
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000




int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    sort(S.begin(), S.end());
    if (S == "abc") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;cin>>n;
    int a[n];
    for (int i=0;i<n;i++)cin>>a[i];
   for (int k=0;k<n-1;k++){cout<<a[k]<<" ";}cout<<a[n-1]<<endl;
    for(int i=1;i<n;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;
        for (int k=0;k<n-1;k++){cout<<a[k]<<" ";}cout<<a[n-1]<<endl;
    }
}



Measured memory_bytes: 3104
apples, base = gets.split.map(&:to_i)

res = 0

if base < 0
  if 0 <= base + apples - 1
    res = 0 
  else
    res = base + apples - 1
  end
else
  res = base
end

puts (base + (base + apples - 1)) * apples / 2 - res

Measured memory_bytes: 1788
n = int(input())
A_cou = 0
Un_cou = 0
ans = "YES"
for i in range(n):
    sen = input()
    if sen == "A":
        A_cou += 1
    else:
        Un_cou += 1
        if A_cou < Un_cou:
            ans = "NO"
            break
if A_cou != Un_cou:
    ans = "NO"
print(ans)
        

Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define S set<int>
#define pb(v) push_back(v)

int main(){
    CIN(A);CIN(B);CIN(C);CIN(D);
    int i = 0;
    REP(a,101){
        if(A<=a&&a<B&&C<=a&&a<D)i++;
    }
    COUT(i);
    return 0;
}


Measured memory_bytes: 256
import math
p = 3.14159
a,b,x = map(int,input().split())
x /= a
if x >= a*b/2:
    print(math.atan(2/(a**2)*(a*b-x))/p*180) 
else:
    print(90-(math.atan((2*x/b**2))/p*180))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 1;i<=n;++i)
using ll = long long;
using P = pair<int,int>;
int f(int a,int k){
  int count = 0;
  while(a < k){
    a *= 2;
    ++count;  
  }
  return count;  
}
int main(){
  int n,k;
  cin >> n >> k;
  double ans = 0;
  rep(i,n){
    ans += pow(0.5,f(i,k));
  }
  cout << setprecision(25) << ans/n << endl;
  return 0;
}


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

int main(void)
{
  int num;
  char string[10005];
  scanf("%d", &num);
  int temp2 = num;
  scanf("%s", string);
  int n = strlen(string);

  for (int i = 0; i < n; i++)
  {
    temp2 = num;
    if (string[i] + num > 'Z')
    {
      int temp = 'Z' - string[i] + 1;
      temp2 -= temp;
      string[i] = 'A';
    }
    string[i] += temp2;
  }
  printf("%s\n", string);
  return 0;
}


Measured memory_bytes: 1668
#include <cmath>
#include <iostream>

int main() {

  int N;
  int K;

  std::cin >> N >> K;
  if (N % K == 0) {
    std::cout << 0 << std::endl;
  } else {
    std::cout << 1 << std::endl;
    }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		String y = sc.next();
		String z = sc.next();
		System.out.println(z + " " + x + " " + y);

		sc.close();
	}

}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n, q;
  cin >> n >> q;
  vector<i64> edge[n];
  for (i64 i = 0; i < n - 1; i++)
  {
    i64 a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  vector<i64> ans(n);
  for (i64 i = 0; i < q; i++)
  {
    i64 p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  vector<bool> tmp(n);
  queue<i64> que;
  que.push(0);
  tmp[0] = true;
  while (que.size())
  {
    i64 p = que.front();
    que.pop();
    for (i64 i : edge[p])
      if (!tmp[i])
      {
        ans[i] += ans[p];
        que.push(i);
        tmp[i]=true;
      }
  }
  for (i64 i = 0; i < n; i++)
    cout << ans[i] << (i + 1 == n ? "\n" : " ");
  return 0;
}


Measured memory_bytes: 17904
int main()
{
  int n;
  scanf("%d", &n);
  int p[n], i;
  for (i = 0; i < n; i++)
    scanf("%d", &p[i]);
  int min = p[0], cnt = 0;
  for (i = 0; i < n; i++)
  {
    if (min >= p[i])
      cnt++;
    if (min > p[i])
      min = p[i];
  }
  printf("%d", cnt);
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <cstdio>
#include <map>
using namespace std;
typedef pair<int,int> P;

int main(){
    map <int,P> data;
    map <int,P>::iterator itr;
    string s;
    int num,tmp;
    while(getline(cin,s) && s.size() > 0){
        sscanf(s.c_str(),"%d,%d",&num,&tmp);
        if(data.find(num) != data.end()) data[num].first++;
        else data.insert(map <int,P>::value_type(num,P(1,1)));
    }
    while(getline(cin,s) && s.size() > 0){
        sscanf(s.c_str(),"%d,%d",&num,&tmp);
        if(data.find(num) != data.end()){
            data[num].first++;
            data[num].second++;
        }
        else data.insert(map <int,P>::value_type(num,P(1,-10000)));
    }
    for(itr=data.begin();itr!=data.end();itr++){
        if(itr->second.first > 1 && itr->second.second > 1) cout << itr->first << " " << itr->second.first << endl;
    }
}

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

int main(){
  string s;int n,ans=1e9;cin>>n>>s;
  vector<int> w(n,0),e(n,0);
  if(s.at(0)=='W') w.at(0)=1;
  if(s.at(n-1)=='E') e.at(n-1)=1;
  for(int i=1;i<n;i++) w.at(i)=w.at(i-1)+(s.at(i)=='W'?1:0);
  for(int i=n-2;i>=0;i--) e.at(i)=e.at(i+1)+(s.at(i)=='E'?1:0);
  REP(i,n){
    int ww=0,ee=0;
    if(i) ww=w.at(i-1);
    if(i!=n-1) ee=e.at(i+1);
    ans=min(ans,ww+ee);
  }
  cout<<ans;
}

Measured memory_bytes: 2948
#include <iostream>

using namespace std;

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

    int* a = new int[n];
    for(int i = 0; i < n; ++i) 
        cin >> a[i];

    int* ans = new int[n];
    for(int i = 0; i < n; ++i)
        ans[a[i] - 1] = i + 1;
    
    for(int i = 0; i < n; ++i)
        cout << ans[i] << " ";
  
 	return 0;
}


Measured memory_bytes: 1664
N, M = gets.split(' ').map(&:to_i)
wars = []
M.times do
	wars.push(gets.split(' ').map(&:to_i))
end
wars.sort_by!{|a,b| b}

r = wars[0][1]
cnt = 1
1.upto(M - 1) do |i|
	l = wars[i][0]
	if l >= r
		cnt += 1
		r = wars[i][1]
	end
end

puts cnt

Measured memory_bytes: 12664
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	s := io.Next()
	var ans string
	if s[len(s)-1] == 's' {
		ans = s + "es"
	} else {
		ans = s + "s"
	}
	io.Println(ans)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
#define Q 22
#define ll long long
#define mo 1000000007
#define ni9 111111112
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
struct Info{int nu,we,nn;}a[Q*2];
int n,q,f[Q*2],bi[Q*2],su[Q],ns,g[Q*2],m;
ll dp[33010][2],an[Q*2];
vector<int> zh[33010],z1[33010];
bool comp(const Info &a,const Info &b){return a.nu<b.nu;}
bool comp1(const Info &a,const Info &b){return a.we<b.we;}
int que(int x){if (f[x]!=x)f[x]=que(f[x]);return f[x];}
void he(int x,int y){int nx=que(x),ny=que(y);if(nx!=ny)f[nx]=ny;}
ll po(ll x,ll y){ll z=1;while (y){if (y%2)z=x*z%mo;x=x*x%mo;y/=2;}return z;}
ll qu(int x,int y){
	int p=0,q=0;ll ans=1;
	for (int i=1;i<=ns;i++)
		if ((x&(1<<(i-1)))!=0)p+=su[i];else if ((y&(1<<(i-1)))!=0)q+=su[i];
	for (int i=1;i<m;i++){
		if ((q&(1<<(i-1)))!=0&&(q&(1<<i))!=0)ans=ans*(an[i]+1)%mo;
		if ((q&(1<<(i-1)))!=0&&(p&(1<<i))!=0)ans=ans*an[i]%mo;
		if ((p&(1<<(i-1)))!=0&&(q&(1<<i))!=0)ans=ans*an[i]%mo;
	}
	return ans;
}
ll qu1(int x,int y){
	int p=0,q=0;ll ans=1;
	for (int i=1;i<=ns;i++)
		if ((x&(1<<(i-1)))!=0)p+=su[i];else if ((y&(1<<(i-1)))!=0)q+=su[i];
	for (int i=1;i<m;i++){
		if ((q&(1<<(i-1)))!=0&&(q&(1<<i))!=0)ans=ans*(an[i]+1)%mo;
		if ((q&(1<<(i-1)))!=0&&(p&(1<<i))!=0)ans=ans*an[i]%mo;
		if ((p&(1<<(i-1)))!=0&&(q&(1<<i))!=0)ans=ans*an[i]%mo;
	}
	if (q%2==1) ans=ans*(an[0]+1)%mo;else ans=ans*an[0]%mo;
	return ans;
}
int main(){
	read(n);read(q);
	for (int i=1;i<=q;i++){read(a[i].nu);a[i].nu--;read(a[i+q].nu);}
	for (int i=1;i<=q+q;i++)a[i].we=i;
	sort(a+1,a+q+q+1,comp);
	for (int i=1;i<=q+q;i++){
		a[i].nn=a[i-1].nn+(i==1||a[i].nu!=a[i-1].nu);
		g[a[i].nn]=a[i].nu;
	}
	m=a[q+q].nn;
	sort(a+1,a+q+q+1,comp1);
	for (int i=1;i<=m;i++) f[i]=i;
	for (int i=1;i<=q;i++)he(a[i].nn,a[i+q].nn);
	for (int i=1;i<=m;i++) if (f[i]==i) bi[i]=++ns;
	for (int i=1;i<=m;i++){
		int no=bi[que(i)];
		su[no]+=(1<<(i-1));
	}
	for (int i=0;i<m;i++)an[i]=(po(10,g[i+1]-g[i])+mo-1)*ni9%mo;
	for (int i=0;i<(1<<ns);i++)zh[0].push_back(i);
	for (int i=1;i<(1<<ns);i++)
		for (int j=0;j<zh[i/2].size();j++)
			if ((zh[i/2][j]&(1<<(ns-1)))==0){
				zh[i].push_back(zh[i/2][j]*2+1);
				if (i%2==0) zh[i].push_back(zh[i/2][j]*2);
			}
	for (int i=0;i<(1<<ns);i++)
		for (int j=0;j<zh[i].size();j++)z1[i].push_back(qu(i,zh[i][j]));
	if (g[1]==0&&m>=1){
		int nu=0;
		for (int i=1;i<=ns;i++) if (su[i]%2==1) nu=i;
		for (int i=0;i<(1<<ns);i++)if ((i&(1<<nu-1))!=0)dp[i][0]=qu(0,i);
	}else{
		for (int i=0;i<(1<<ns);i++) dp[i][0]=qu1(0,i);
	}
	for (int ne=1;ne<=8;ne++){
		for (int j=0;j<(1<<ns);j++)
			if (dp[j][0])
				for (int i=0;i<zh[j].size();i++)
					dp[zh[j][i]][1]=(dp[zh[j][i]][1]+dp[j][0]*z1[j][i])%mo;
		for (int j=0;j<(1<<ns);j++){dp[j][0]=dp[j][1];dp[j][1]=0;}
	}
	ll ans=dp[(1<<ns)-1][0];
	cout<<ans*po(10,n-g[m])%mo<<endl;
	return 0;
}
/*
30 10
1 1
3 3
5 5
7 7
9 9
11 11
13 13
15 15
17 17
19 19
*/

Measured memory_bytes: 117504
fun c92(args: Array<String>) {
    val numList = listOf(0).plus(args[1].split(" ").map { it.toInt() }).plus(0)
    val cost = (0..numList.size - 2).map { Math.abs(numList[it + 1] - numList[it]) }.sum()

    val ans = (0..numList.size - 3)
            .map {
                val before = Math.abs(numList[it + 2] - numList[it + 1]) + Math.abs(numList[it + 1] - numList[it])
                val after = Math.abs(numList[it + 2] - numList[it])
                cost - (before - after)
            }
            .joinToString("\n")

    println(ans)
}

fun main(args: Array<String>) {
    c92(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 59544
import math
N = int(input())
A = list(map(int,input().split()))
D = {}
for i in A :
    if i in D :
        D[i] += 1
    else :
        D[i] = 1

ans = 0
A = sorted(A,reverse=True)
for i in A :
    r = 2**math.ceil(math.log2(i))
    if i == r :
        ans += (D[i] // 2)
        D[i] = 0
    else :
        b = r-i
        if D[i] > 0 and D.get(b,0) > 0 :
            D[i] -= 1
            D[b] -= 1
            ans += 1
print(ans)


Measured memory_bytes: 33040
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

double height[501],range_height[501][501];
double dp[501][501];

int main(){

	int N,M;
	scanf("%d %d",&N,&M);

	height[0] = 0;
	for(int i = 1; i <= N; i++){
		scanf("%lf",&height[i]);
		height[i] += height[i-1];
	}

	double sum;

	for(int left = 1; left <= N; left++){
		for(int right = left; right <= N; right++){
			sum = height[right]-height[left-1];
			range_height[left][right] = sum/(double)(right-left+1);
		}
	}

	for(int right = 0; right <= N; right++){
		for(int num = 0; num <= M; num++)dp[right][num] = 0.0;
	}

	for(int right = 1; right <= N; right++){
		for(int left = 1; left <= right; left++){
			for(int divide_num = 1; divide_num <= min(right,M); divide_num++){
				if(divide_num == 1 && left != 1)continue;
				if(left-1 < divide_num-1)break;
				dp[right][divide_num] = max(dp[right][divide_num],dp[left-1][divide_num-1]+range_height[left][right]);
			}
		}
	}

	//return 0;

	printf("%.10lf\n",dp[N][M]);

	return 0;
}



Measured memory_bytes: 7144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Console.ReadLine().ToCharArray().Where(x => x == 'o').Count() * 100 + 700);
        }
    }

}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long a[N], dp[N][N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  dp[0][0] = a[0];
  for (int j = 1; j < N; j++) {
    dp[j][j] = a[j];
    for (int i = j-1; i+1; i--) {
      dp[i][j] = max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
    }
  }
  cout << dp[0][N-1];
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main() {
    int n;
    cin >> n;
    vector<string> S;
    rep(i, n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        S.push_back(s);
    }
    string ch = S[0];
    rep(i, n - 1) {
        string ans = "";
        int start, end;
        start = end = 0;
        while (true) {
            if (ch[start] != S[i + 1][end]) {
                if ((ch[start] - 'a') > (S[i + 1][end] - 'a')) {
                    end++;
                } else {
                    start++;
                }
            } else {
                ans += ch[start];
                start++;
                end++;
            }
            if (start == ch.length()) {
                break;
            }
            if (end == S[i + 1].length()) {
                break;
            }
        }
        ch = ans;
        if (ch.empty()) {
            cout << "" << endl;
            return 0;
        }
    }
    cout << ch << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    while(N != 0){
        ll sum = 0;
        int ans = 0;
        int ans_l = -1;
        for(int i=1; i<=100000; i++){
            if(N < sum) break;
            if(N == sum){
                ans = i-1;
                ans_l = 1;
                break;
            }
            if((N-sum)%i == 0){
                ans = i;
                ans_l = (N-sum)/i;
            }
            sum += i;
        }
        cout << ans_l << " " << ans << enld;
        cin >> N;
    }
    return 0;
}



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

using namespace std;

typedef long long LL;

const int N = 100010;

string s;

int main()
{
    cin >> s;
    for(int i = s.size() - 2; i > 0; i -= 2)
    {
        string t1 = s.substr(0, i / 2);
        string t2 = s.substr(i / 2, i / 2);
        if(t1 == t2)
        {
            cout << i << endl;
            return 0;
        }
    }

    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  string s,t;
  cin >> s >> t;
  int ans = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == t[i] ){
      ans++;
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
using ll = long long;
const ll INF = 100100100;
template <typename T> inline bool chmin(T& a, T b) { 
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline bool chmax(T& a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

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

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int i = 0; i < 3; ++i) chmax(res, dp[N][i]);
    cout << res << endl;
}

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

int a, b;

int main() {
	cin >> a >> b;
	if (a == 1) a += 13;
	if (b == 1) b += 13;
	if (a > b) { cout << "Alice" << endl; }
	else if (a < b) { cout << "Bob" << endl; }
	else { cout << "Draw" << endl; }
	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

    vector<ll> L(N);
    vector<ll> D(N+1);
    D[0] = 0;
    REP(i, N){
        cin >> L[i];
        D[i+1] = D[i] + L[i];
    }
    REP(i, N+1){
        if(D[i] > X){
            cout << i << endl;
            return 0;
        }
    }
    cout << N+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <limits>
#include <vector>
#define ll long long
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

vector<vector<int> > vec;
//vector<pair<int,int> > p(Q);
vector<int> ans;

void dfs(int c,int p){
    rep(i,vec[c].size()){
        if(vec[c][i] != p){
            ans[vec[c][i]] += ans[c];
            dfs(vec[c][i],c);
        }
    }
}

int main(){

    int N,Q;
    cin >> N >> Q;

    vec.resize(N);
    ans.resize(Q);

    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        vec[a].pb(b);
        vec[b].pb(a);
    }

    rep(i,Q){
        int y,x;
        cin >> y >> x;
        y--;
        ans[y] += x;
    }

    dfs(0,-1);

    rep(i,N){
        cout << ans[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans=INF;
    rep(i,101){
        ll u=0;
        rep(j,n){
            u+=(i-a[j])*(i-a[j]);
        }
        ans=min(ans,u);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def solve():
    cnt = 0
    ans = 0
    for i in range(N-1):
        if H[i] >= H[i+1]:
            cnt += 1
            ans =max(ans, cnt)
        else:
            cnt = 0
    print(ans)

if __name__ == "__main__":
    N = int(input())
    H = list(map(int, input().split()))
    solve()  


Measured memory_bytes: 20596
#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=1e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int get(int x){
    int res=0;
    for(;x;x/=10){
        res+=x%10;
    }
    return res;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int ans=inf;
    for(int i=1;i<n;i++){
        ans=min(ans,get(i)+get(n-i));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();

        String ans = "";
        if (s.length() <= k) ans = s;
        else {
            ans = s.substring(0, k) + "...";
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 38644
#include<stdio.h>
int main(){
	char S[3];
	scanf("%s",&S);
	if (S[0]==S[1] && S[1]==S[2] && S[2]==S[0]){
		printf("No");
	}
	else if(S[0]==S[1] || S[1]==S[2] || S[2]==S[0]){
		printf("Yes");
	}
	else {
		printf("No");
	}
}

Measured memory_bytes: 1680
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cassert>
using namespace std;

void chmin(int &x,int y){x=min(x,y);}

int n,m;
vector<pair<int,int>> bomb;
vector<pair<int,int>> g[1<<17];
bool is[1<<17];
bool odd[1<<17];
vector<int> ans;

bool dfs(int v)
{
    if(is[v]) return false;
    bool res=odd[v];
    is[v]=true;
    for(auto& e:g[v])
    {
        int u,i; tie(u,i)=e;
        if(dfs(u))
        {
            ans.emplace_back(i);
            res=not res;
        }
    }
    return res;
}

main()
{
    cin>>n>>m;
    for(int i=0;i<n;++i)
    {
        int a,b; cin>>a>>b;
        bomb.emplace_back(a,b);
    }
    bomb.emplace_back(0,0);
    bomb.emplace_back(1e9+1,0);
    sort(begin(bomb),end(bomb));
    for(int i=1;i<=m;++i)
    {
        int l,r; cin>>l>>r; ++r;
        l=lower_bound(begin(bomb),end(bomb),pair<int,int>{l,0})-begin(bomb)-1;
        r=lower_bound(begin(bomb),end(bomb),pair<int,int>{r,0})-begin(bomb)-1;
        assert(l<=n);
        assert(r<=n);
        g[l].emplace_back(r,i);
        g[r].emplace_back(l,i);
        // cerr << "edge: " << l << " " << r << "\n";
    }
    for(int i=0;i<=n;++i)
    {
        odd[i]=(bomb[i].second!=bomb[i+1].second);
    }
    for(int i=0;i<=n;++i)
    {
        if(dfs(i))
        {
            // cerr << "out at: " <<  i << "\n";
            cout << -1 << "\n";
            return 0;
        }
    }
    cout << ans.size() << "\n";
    sort(begin(ans),end(ans));
    for(auto &e:ans)
    {
        cout << e << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 14708
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}


int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int h, n, a[100000];
int cnt;

signed main() {
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt += a[i]; 
	}
	if (h <= cnt)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1024
import Foundation

let array1 = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }
let N = array1[0]
let K = array1[1]
var array =  readLine()!.componentsSeparatedByString(" ").map { Double($0)! }
var sums = [0.0]
for i in 0 ..< N {
  sums.append(sums[i] + ((1 + array[i]) * 0.5))
}
var answers = [Double]()
for j in 0 ... N - K {
  answers.append(sums[j + K] - sums[j])
}
//answers = answers.sort { $0 > $1 } 
print(answers.maxElement()!)

Measured memory_bytes: 10864
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;
int a,b,q;
long long in;
int main(){
    cin>>a>>b>>q;
    vector<long long> s,t,x(q);
    s.push_back(-1e12);
    t.push_back(-1e12);
    for(int i=0;i<a;i++)cin>>in,s.push_back(in);
    for(int i=0;i<b;i++)cin>>in,t.push_back(in);
    for(int i=0;i<q;i++)cin>>x[i];
    s.push_back(1e12);
    t.push_back(1e12);
    for(int i=0;i<q;i++){
        auto Itr1=upper_bound(s.begin(),s.end(),x[i])-1;
        auto Itr2=upper_bound(s.begin(),s.end(),x[i]);
        auto Itr3=upper_bound(t.begin(),t.end(),x[i])-1;
        auto Itr4=upper_bound(t.begin(),t.end(),x[i]);
        long long A[2]={*Itr1,*Itr2},B[2]={*Itr3,*Itr4};
        long long ans=1e18;
        for(int k=0;k<2;k++){
            for(int j=0;j<2;j++){
                ans=min(min(abs(A[k]-x[i]),abs(B[j]-x[i]))+abs(A[k]-B[j]),ans);
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3828
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string t = Console.ReadLine();
			int n = s.Length;

			var sc = new int[26];
			var tc = new int[26];
			for (int i = 0; i < n; i++) {
				sc[s[i] - 'a']++;
				tc[t[i] - 'a']++;
			}

			Array.Sort(sc);
			Array.Sort(tc);

			for (int i = 0; i < 26; i++) {
				if (sc[i] != tc[i]) {
					Console.WriteLine("No");
					return;
				}
			}

			Console.WriteLine("Yes");
		}
	}
}

Measured memory_bytes: 13208
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{

    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

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

int main()
{
    string s;
    cin >> s;
    ll k;
    cin >> k;
    bool flag = false;
    char tmp;
    if (k == 1)
    {
        cout << s.at(0) << endl;
    }
    else
    {
        for (int i = 0; i < k; i++)
        {
            if (s.at(i) != '1')
            {
                flag = true;
                tmp = s.at(i);
                break;
            }
        }
        if (flag)
        {
            cout << tmp << endl;
        }
        else
        {
            cout << s.at(k - 1) << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int, int> P;



int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> b(n);
    int cnt = 0;

    for (int i=n-1; i>=0; i--) {
        if (n/(i+1) == 0) {
            b[i] = a[i];
            continue;
        }
        int tmp = 0;
        for (int j=2*i+1; j<n; j+=i+1) {
            tmp += b[j];
        }
        tmp %= 2;
        if (tmp == a[i]) b[i] = 0;
        else {
            b[i] = 1;
            cnt++;
        }

    } 

    cout << cnt << endl;
    rep(i, n) {
        if (b[i] == 1) {
            cout << i+1 << endl;
        }
    }

}

Measured memory_bytes: 2432
N = int(input().split()[0])
h_list = list(map(int, input().split()))

tentou_list = []

for i in range(N-1):
    if h_list[i] >= h_list[i+1]:
        t = 1
    else:
        t = 0
    tentou_list.append(t)

# 一番長い1はどれか
c = 0
c_list = []

for t in tentou_list:
    if t == 0:
        c_list.append(c)
        c = 0
    else:
        c += 1

if tentou_list:
    if t == 1:
        c_list.append(c)
    ans = max(c_list)
else:
    ans = 0

print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N; cin >> N;
    vector<ll> A(N); rep(i,N) cin >> A[i];

    ll S = 0;
    rep(i,N) S += A[i];
    S /= 2;

    ll X = 0;
    for(int i=0;i<N;i+=2){
        X += A[i];
    }

    /* debug(S); */
    /* debug(X); */

    vector<ll> x(N,0);
    x[0] = X - S;

    for(int i=0;i<N;i++){
        if(i+1>=N) continue;
        x[i+1] = A[i] - x[i];
    }
    rep(i,N){
        cout << x[i]*2 << " ";
    }
    cout << endl;
}


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

int main() {
    int m, d, n, b;
    cin >> m;
    cin >> d;
    cin >> n;
    cin >> b;
    if(b == 1) {
        cout << 1 << '\n';
    } else {
        cout << 0 << '\n';
    }
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define sc second
#define ve vector
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define rep1(i, n) repi(i, 1, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// abs 絶対値, rtsq ルート, pow(a, n) aのn乗

int main() {
  int N, T, X, Y;
  st a = "Yes";
  ci(N);
  ve<int> t(N + 1), x(N + 1), y(N + 1);
  t.at(0) = 0;
  x.at(0) = 0;
  y.at(0) = 0;
  rep(i, N) {
    ci(t.at(i + 1), x.at(i + 1), y.at(i + 1));
  }
  rep(i, N) {
    T = abs(t.at(i + 1) - t.at(i));
    X = abs(x.at(i + 1) - x.at(i));
    Y = abs(y.at(i + 1) - y.at(i));
    if(T < X + Y || (T - X - Y) % 2 != 0) {
      a = "No";
    }
  }
  co(a);
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var N = ReadInt();
            var S = Read();
            var x = 0;
            var max = 0;
            foreach (var s in S)
            {
                if (s == 'I')
                {
                    x++;
                }

                if (s == 'D')
                {
                    x--;
                }

                max = Math.Max(max, x);
            }
            Println(max);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();

        static void Print(object value = null) => Console.Write(value.ToString());
        static void Println(object value = null) => Console.WriteLine(value.ToString());
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
/*
  if(u == NIL || k == u->key)
    return u;
  if(k < u->key)
    return treeSearch(u->left, k);
  else
    return treeSearch(u->right, k);
*/
  while(u != NIL && k != u->key){
    if(k < u->key)
      u = u->left;
    else
      u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if(x->right != NIL)
    return treeMinimum(x->right);
  Node y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  int tmp;

  if(z->left == NIL || z->right == NIL)
    y = z;
  else
    y = treeSuccessor(z);
  if(y->left != NIL)
    x = y->left;
  else
    x = y->right;
  if(x != NIL)
    x->parent = y->parent;
  if(y->parent == NIL)
    root = x;
  else if(y == y->parent->left)
    y->parent->left = x;
  else
    y->parent->right = x;
  if(y != z){
    z->key = y->key;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;

  if(y == NIL)
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

void inorder(Node u){
  if(u->left != NIL)inorder(u->left);
  printf(" %d", u->key);
  if(u->right != NIL)inorder(u->right);
}
void preorder(Node u){
  printf(" %d", u->key);
  if(u->left != NIL)preorder(u->left);
  if(u->right != NIL)preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll N , t = 1 , m = 1e9 + 7;
    cin >> N;
    for(int i = 0; i++ < N; i){
        t = t * i % m;
    }
    cout << t << endl;
}

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

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;
}
struct Unionfind {
    vector<int> par;

    Unionfind(int n) : par(n) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] =ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

ll f(ll n) {
    return (n * (n+1)) / 2;
}

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

    int n;
    cin >> n;
    ll ans = 0;

    for(int i = 1; i <= n; ++i) {
        ll v = n / i;
        ans += f(v) * i;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long llint;

int a[50], b[50];
set<llint> ways[50];

void solve(int i, int x)
{
	static llint cur = 0;
	
	if (x == b[i])
	{
		ways[i].insert(cur);
		return;
	}
	if (x < b[i])
	{
		return;
	}
	
	for (int y = 1; y <= x; ++y)
	{
		cur ^= 1ll<<y;
		solve(i, x % y);
		cur ^= 1ll<<y;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, i;
	
	cin>>n;
	
	for (i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	for (i = 0; i < n; ++i)
	{
		cin>>b[i];
		
		solve(i, a[i]);
		
		if (ways[i].empty())
		{
			cout<<"-1\n";
			return 0;
		}
	}
	
	llint sol = 0;
	for (int l = 50; l >= 0; --l)
	{
		bool needsome = false;
		for (i = 0; i < n; ++i)
		{
			bool needthis = true;
			for (llint x: ways[i]) if (!(x & 1ll<<l))
			{
				needthis = false;
				break;
			}
			if (needthis)
			{
				needsome = true;
				break;
			}
		}
		if (needsome)
		{
			sol ^= 1ll<<l;
		}
		else
		{
			for (i = 0; i < n; ++i)
			{
				for (auto it = ways[i].begin(); it != ways[i].end(); )
				{
					if (*it & 1ll<<l)
					{
						it = ways[i].erase(it);
					}
					else ++it;
				}
			}
		}
	}
	
	cout<<sol<<'\n';
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    bool a[26] = {};
    for (int i = 0; i < s.length(); i++) {
//        cout << s[i] - '0' - 49 << endl;
        a[s[i]-'0'-49] = true;
    }
    string ans = "None";
    for (int i = 0; i < 26; i++) {
        if (!a[i]) {
            ans = 'a' + i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512