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

int n;
int a[3][105],dp[3][105];

int main() {
    scanf("%d",&n);
    for (int i=0; i<2; i++)
	for (int j=0; j<n; j++) {
		scanf("%d",&a[i][j]);
	}
	memset(dp,0,sizeof(dp));
	dp[0][0] = a[0][0];
	for (int i=0; i<2; i++)
	for (int j=0; j<n; j++) {
		if (i>0) dp[i][j] = max(dp[i][j],dp[i-1][j]+a[i][j]);
		if (j>0) dp[i][j] = max(dp[i][j],dp[i][j-1]+a[i][j]);
	}
	printf("%d\n",dp[1][n-1]);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

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

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int n; cin >> n;
	if (n < 1000)cout << "ABC" << endl;
	else cout << "ABD" << endl;
	return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,ans;
int main()
{
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
        int x=i/10000,y=i/1000%10;
        if(x==i%10&&y==i/10%10)
            ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX_T=3000;
const int MAX_N=3000;
int main(){
    int N,T,S,dp[2][MAX_T+1]={{0}},A[MAX_N],B[MAX_N];
    cin>>N>>T>>S;
    for(int i=0;i<N;i++)cin>>A[i]>>B[i];

    for(int i=0;i<N;i++){
        int a=A[i],b=B[i];
        for(int j=1;j<=T;j++){
            dp[i&1][j]=max(dp[(i+1)&1][j],dp[i&1][j-1]);
            if(j-b>=0&&(!(j-b<S&&j>S)))dp[i&1][j]=max(dp[i&1][j],dp[(i+1)&1][j-b]+a);
        }
    }
    cout<<dp[(N-1)&1][T]<<endl;
}

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

namespace _159_A
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var a = Console.ReadLine()
                .Split()
                .Select(int.Parse)
                .ToArray();

            Console.WriteLine((
                (a[0] <= 1 ? 0 : a[0] * (a[0] - 1) / 2)
                + (a[1] <= 1 ? 0 : a[1] * (a[1] - 1) / 2))
                .ToString());
        }
    }
}

Measured memory_bytes: 13268
N = int(input())
a = list(map(int, input().split()))
r = 2 * N
ans = 0
a.sort(reverse=True)
if a[0] > 10**9:
    exit()
a_choiced = a[0:r][1::2]
for i in a_choiced:
    ans += i
print(ans)

Measured memory_bytes: 39492
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    S=input()
    for i in range(len(S)-1):
        if S[i]=="A" and S[i+1]=="C":
            print("Yes")
            break
    else:print("No")
#%%submit!
resolve()



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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    while(true){
        string s;
        cin >> s;
        if(s=="0") break;

        int ans=0;
        for(int i=0;i<s.size();i++) ans+=s[i]-'0';

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


Measured memory_bytes: 3180
X,Y,i;x[12],y[12];q[9999],t,h,p,o,c;char*d="22210/.../01";main(n){for(;scanf("%d%d",&X,&Y),X;puts(o?"OK":"NA")){for(o=t=h=i=!scanf("%d",&n);i++<n;)scanf("%d%d",x+i,y+i);for(p=q[t++]=X*10+Y;t!=h&!o;p=q[h++])if(!(c=p/100)||abs(x[c]-p/10%10)<2&abs(y[c]-p%10)<2)for(o=c++==n,i=0;i<12;X>=0&X<10&Y>=0&Y<10?q[t++]=c*100+X*10+Y:0)X=p/10%10+d[i]-48,Y=p%10+d[11-i++]-48;}}

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

int main()
{
  int64_t N, W, w, v;
  cin >> N >> W;
  vector<pair<int64_t, int64_t>> wv(N + 1);
  for (int i = 1; i <= N; i++)
  {
    cin >> w >> v;
    wv.at(i) = make_pair(w, v);
  }
  vector<vector<int64_t>> DP(N + 1, vector<int64_t>(W + 1, 0));
  for (int n = 1; n <= N; n++)
  {
    for (int w = 1; w <= W; w++)
    {
      int64_t a = 0; //選ぶ
      if (w - wv.at(n).first >= 0)
      {
        a = DP.at(n - 1).at(w - wv.at(n).first) + wv.at(n).second;
      }
      int64_t b = DP.at(n - 1).at(w); //選ばない
      DP.at(n).at(w) = (a >= b) ? a : b;
    }
  }
  cout << DP.at(N).at(W) << endl;
}


Measured memory_bytes: 80256
#include<iostream>
#include<cstdio>

const int MAXN=2005;

int n,m,q;
int fV[MAXN][MAXN],fR[MAXN][MAXN],fC[MAXN][MAXN];

inline int calc(int f[MAXN][MAXN],int x1,int y1,int x2,int y2)
{return f[x2][y2]-f[x1-1][y2]-f[x2][y1-1]+f[x1-1][y1-1];}

int main()
{
	int i,j;scanf("%d%d%d",&n,&m,&q);
	for(i=1;i<=n;i++) for(j=1;j<=m;j++)
	{
		char c;do c=getchar();while(c!='0'&&c!='1');
		fV[i][j]= c=='1';
	}
	for(i=1;i<=n;i++) for(j=1;j<=m;j++)
		if(fV[i][j]) fR[i][j]+=fV[i+1][j],fC[i][j]+=fV[i][j+1];
	for(i=1;i<=n;i++) for(j=1;j<=m;j++)
		fV[i][j]+=fV[i][j-1],fR[i][j]+=fR[i][j-1],fC[i][j]+=fC[i][j-1];
	for(j=1;j<=m;j++) for(i=1;i<=n;i++)
		fV[i][j]+=fV[i-1][j],fR[i][j]+=fR[i-1][j],fC[i][j]+=fC[i-1][j];
	while(q--)
	{
		int x1,y1,x2,y2;scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		int ans=calc(fV,x1,y1,x2,y2)-calc(fR,x1,y1,x2-1,y2)-calc(fC,x1,y1,x2,y2-1);
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 48896
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	for(int i=0;i<=1000;i++)if(((int)(i*0.08))==a&&((int)(i*0.1))==b)
	{
		printf("%d\n",i);
		return 0;
	}
	puts("-1");
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int a[3];
  	rep(i,3) cin >> a[i];
  	sort(a, a+3);
  	cout << a[2]*10 + a[1] + a[0] << endl;
  	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[233],b,c;
int main(){
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+4);
    if(a[2]-a[1]==a[3]-a[2]){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=b)
    {
        for(int i=0;i<a;i++)
        {
            cout<<b;
        }
        return 0;
    }
    else
    {
        for(int i=0;i<b;i++)
        {
            cout<<a;
        }
        return 0;
    }
    
    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 n = Integer.parseInt(sc.next());
		String s = sc.next();
		String t = sc.next();
		String buff = "";

		for(int i =0;i<n;i++) {
			buff = buff + s.substring(i,i+1)+t.substring(i,i+1);
		}

		System.out.println(buff);


	}

}


Measured memory_bytes: 21716
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


//////////////////////////////////////
#define MAX_N 1000000//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
int par[MAX_N],dep[MAX_N];//depはrankのこと
//n要素で初期化
void init(int n){
    for(int i=0;i<=n-1;i++){
        par[i]=i;
        dep[i]=0;
    }
}
//木の根を求める
int find(int x){
    return par[x]==x?x:par[x]=find(par[x]);
}
//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(dep[x]<dep[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(dep[x]==dep[y])dep[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
    return find(x)==find(y);
}
//////////////////////////////////////
struct edge{int u,v,cost;};
bool comp(const edge& e1,const edge& e2){
    return e1.cost<e2.cost;
}
#define MAX_E 1000000//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
edge es[MAX_E];
int v,e;//頂点数vと辺数e

int kruskal(){
    sort(es,es+e,comp);
    init(v);
    int res=0;
    for(int i=0;i<e;i++){
        edge e=es[i];
        if(!same(e.u,e.v)){
            unite(e.u,e.v);
            res+=e.cost;
        }
    }
    return res;
}
///////////////////////////////////////////

struct point{
    i_i xy;
    int num;
};
bool comp1(point x,point y){
    return x.xy.first<y.xy.first;
}
bool comp2(point x,point y){
    return x.xy.second<y.xy.second;
}

int main(){
    cin>>v;
    e=2*v-2;
    
    point pp[v];
    rep(i,0,v-1){
        pp[i].num=i;
        cin>>pp[i].xy.first>>pp[i].xy.second;
    }
    sort(pp,pp+v,comp1);
    rep(i,0,v-2){
        es[i].u=pp[i].num;
        es[i].v=pp[i+1].num;
        es[i].cost=pp[i+1].xy.first-pp[i].xy.first;
    }
    sort(pp,pp+v,comp2);
    rep(i,0,v-2){
        es[v-1+i].u=pp[i].num;
        es[v-1+i].v=pp[i+1].num;
        es[v-1+i].cost=pp[i+1].xy.second-pp[i].xy.second;
    }
    
    cout<<kruskal()<<endl;
    
    
    return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <string>
#include <functional>
#include <cassert>
#include <cmath>
#define SIZE 200005
#define MOD 1000000007
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char str[SIZE];

int main(){
    int n;
    scanf("%d", &n);
    scanf("%s", &str);
    
    char pre_s = str[0];
    int left = 1;
    int right = 0;
    int reverse = 1;
    ll ret = 1;
    for(int i=1; i<2*n; i++)
    {
        if(pre_s == str[i]) reverse *= -1;
        if(reverse == 1) left++;
        else if(reverse == -1)
        {
            ret = (ret * (left - right)) % MOD;
            right++;
        }
        pre_s = str[i];
    }
    if(left == right && (str[0] == 'B' || str[2*n-1] == 'B'))
    {
        for(int i=1;i<=n;i++) ret = (ret * i) % MOD;
    }
    else ret = 0;
    printf("%lld\n", ret);

    return 0;
}


Measured memory_bytes: 384
def solve():
    N, M = map(int, input().split())
    A = []
    if M != 0:
        A = [int(input()) for _ in range(M)]
    A.sort(reverse=True)
    mm = 10 ** 9 + 7
    dp = [0] * (N + 1)
    dp[0] = 1  # 0段目に行くパターンは1とする
    tag = -1
    if len(A) != 0:
        tag = A.pop()
    # 1段目のパターンを設定
    if tag == 1:
        dp[1] = 0
        if len(A) == 0:
            tag = -1
        else:
            tag = A.pop()
    else:
        dp[1] = 1
    for i in range(2, N + 1):
        if i == tag:
            if len(A) == 0:
                tag = -1
            else:
                tag = A.pop()
            continue
        dp[i] = (dp[i - 1] + dp[i - 2]) % mm
    print(dp[N])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 7848
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

use std::cmp::*;

fn main() {
    let nm: Vec<usize> = read_vec();
    let n = nm[0];
    let m = nm[1];
    // 対象となるスイッチを表すbit列
    // ex. スイッチが5個で、i個目の電球に紐づいたスイッチが1,2,5
    // => 10011
    let mut bits: Vec<u64> = vec![0; m];

    for i in 0..m
    {
        let km: Vec<u32> = read_vec();
        for j in 0..km[0] as usize
        {
            bits[i] += 1 << (km[1 + j] - 1);
        }
    }

    let p: Vec<u32> = read_vec();
    let mut result: u64 = 0;

    // n個のスイッチに関してbit全探索
    'outer: for bp in 0..1 << n
    {
        // 各電球が点灯するか調べる, 点灯しないパターンが存在する場合はcontinue
        for i in 0..m
        {
            // AND
            let and = bits[i] & bp;
            if and.count_ones() % 2 != p[i] { continue 'outer; }
        }

        result += 1;
    }

    println!("{}", result);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+1;
const int mod = 1e9+7;
int main() {
	string s;
	cin >> s;
	if((s[2]==s[3])&&(s[4]==s[5])) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

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

using namespace std;
int main(){
    long n;
    int k,h,count=0;
    cin >> n >> k;
    for(int i=0; i<n; i++){
      cin >> h;
      if(h>=k)
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3560
using System;
using System.Collections.Generic;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題169

            int N = int.Parse(Console.ReadLine());

            string[] line = Console.ReadLine().Split(' ');

            long[] A = new long[N];

            for (int i=0; i<N; i++)
            {
                //Console.WriteLine(i);
                A[i] = long.Parse(line[i]);
                //Console.WriteLine(A[i]);

                if (A[i] == 0)
                {
                    Console.WriteLine(0);
                    return;
                }
            }


            long ans = 1;
            for (int i =0; i < N; i++)
            {
                if (ans > 1000000000000000000/A[i])
                {
                    Console.WriteLine(-1);
                    return;
                }

                ans *= A[i];



            }

            Console.WriteLine(ans);

        }


    }
}


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

int main() {
	UL X; cin >> X;
	UL N; cin >> N;
	set<UL> P;
	rep(i, N) {
		UL p; cin >> p;
		P.insert(p);
	}
	for (UL i = 0;; i++) {
		if (P.count(X - i) == 0) { cout << X - i << endl; break; }
		if (P.count(X + i) == 0) { cout << X + i << endl; break; }
	}

	return 0;
}


Measured memory_bytes: 3616
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int n;
	while (cin >> n, n) {
		int a[30];
		rep(i, n) cin >> a[i];

		int ohajiki = 32,idx = 0;
		while (ohajiki > 0) {
			ohajiki -= (ohajiki - 1) % 5;
			cout << ohajiki << endl;
			if (ohajiki - a[(idx + n) % n] < 0)
				ohajiki = 0;
			else
				ohajiki -= a[(idx + n) % n];
			idx++;
			cout << ohajiki << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,n,i = 0,j = -1,t = 0;scanf("%d%d%d",&h,&w,&n);
  int a[n],c[h][w];
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  i = 0;
  while(t<n){
    if(((j+2)%2 && i==0) || (j%2==0 && i==h-1)) j++;
    else if(j%2==0) i++;
    else i--;
    c[i][j] = t+1;a[t]--;
    if(a[t]==0) t++;
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++) printf("%d ",c[i][j]);
    printf("\n");
  }
}

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

int main()
{
    int M,D;
    cin>>M>>D;
    int a,b;
    int t = 0;
    for (int i = 1;i < M+1;i++) {
        for (int j = 1;j < D+1;j++) {
            a = j/10;
            b = j%10;
            if (a*b == i && a >= 2 && b >= 2){
                t+=1;
            }else{
                t+=0;
            }
        }
    }
    cout<<t<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b,c,d,x,y,v,w;
  
 cin>>a>>b>>c>>d;
 x=a*c ; y=a*d;
 w=b*c ; v=b*d;
  
  cout<<max(x,max(y,max(w,v)));
  
}

Measured memory_bytes: 3632
#include<iostream>
    #include<string>
    #include<algorithm>
    using namespace std;
    int main(){
        string S;
        cin>>S;
        int res=S.size();
        int a=S.size();
        for(int i=1;i<S.size();i++){
            if(S[i]!=S[i-1])
                res=min(res,max(i,a-i));
        }
        cout<<res<<endl;
        return 0;
    }


Measured memory_bytes: 512
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	char s[20];
	scanf("%s", s);
	s[3] = '\0';
	printf("%s", s);
	return 0;
}

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

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int q=0,w=0,e=0;
    for (int i = 0; i < n; ++i) {
        int t;
        cin>>t;
        if(t<=a)++q;
        else if(t<=b)++w;
        else ++e;
    }
    cout<<min(min(q,w),e)<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

if len(S) < 26:
  N = [chr(i) for i in range(97,123) if chr(i) not in S]
  print(S + N[0])
else:
  for i in range(26):
    for j in range(i+1):
      if S[-(i + 1)] < S[-(j + 1)]:
          print(S[:-(i+1)]+S[-(j+1)])
          exit()
  else:
    print(-1)


Measured memory_bytes: 3064
def main():
    alpha = [0 for i in range(ord('z')+1)]

    flag = 1
    for s in input():
        if alpha[ord(s)] == 1:
            flag = 0
            break
        alpha[ord(s)] = 1

    if flag: print("yes")
    else: print("no")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.math.*;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        boolean allEven = true;
        for (int i = 0; i < n; i++) {
            long a = Long.parseLong(scanner.nextLine());
            if (a % 2 != 0) {
                allEven = false;
            }
        }
        if (allEven) {
            System.out.println("second");
        } else {
            System.out.println("first");
        }
    }
}


Measured memory_bytes: 94640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>

using namespace std;

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

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

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

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

#define PQ priority_queue

#define FST first
#define SEC second

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

//------------------HEAD---------------------

int dp[200][200];

int D,N;
int A[200],B[200],C[200];
int T[200];
/*
int solve(int d, int a){
    //d??\?????????a??????????????????d????????§
    if(dp[d][a]!=INF){
        return dp[d][a];
    }

    int res=0;

    rep(i,N){
        //d-1??\???????????¶?????????????±???????
        if(RANGE(A[i],T[d],B[i]+1)){
            res=max(res, solve[d-1][i]);
        }
    }
    dp[d][a]=res;

}
*/


int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>D>>N;
    rep(i,D){
        int t;
        cin>>t;
        T[i]=t;
    }
    rep(i,N){
        int a,b,c;
        cin>>a>>b>>c;
        A[i]=a;
        B[i]=b;
        C[i]=c;
    }
    rep(i,D)rep(j,N)dp[i][j]=-INF;

    rep(a,N){
        if(RANGE(A[a],T[0],B[a])){
            dp[0][a]=0;
        }
    }

    FOR(d,1,D){
        rep(a,N){
            if(RANGE(A[a],T[d],B[a])){
                int res=-INF;
                rep(i,N){
                    //d-1??\???????????¶?????????????±???????
                    if(dp[d-1][i]!=-INF){
                        res=max(res, dp[d-1][i]+abs(C[i]-C[a]));
                    }
                }
                dp[d][a]=res; 
            }
        }
    }
    int res=-INF;
    rep(i,N){
        //D??\???????????¶?????????????±???????
        res=max(res, dp[D-1][i]);
        
    }
    cout<<res<<endl; 


    return 0;
}


Measured memory_bytes: 3360
#define _USE_MATH_DEFINES
#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;
typedef pair<int, int> pii;

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

    ll k;
    cin >> k;
    int cnt = 0;
    rep(i, s.size())
    {
        if (s[i] != '1')
        {
            cnt = i;
            break;
        }
    }

    cnt + 1 > k ? OP(1) : OP(s[cnt]);
    return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
  
k = int(input())
s = 0
l = []
for i in range(k):
  for j in range(k):
    l.append(math.gcd(i+1,j+1))
for h in range(k):
  for n in l:
    s += math.gcd(h+1, n)
print(s)


Measured memory_bytes: 9848
h, w = [int(item) for item in input().split()]

lists = [[0] * w] * h

for i in range(h):
  lists[i] = [int(item) for item in input().split()]

count = 0
operations = ""
for i, l in enumerate(lists):
  for j, a in enumerate(l):
    if j == w-1:
      break
    if a%2 == 1:
      lists[i][j] -= 1
      lists[i][j+1] += 1
      count += 1
      operations += str(i+1,) + " " + str(j+1) + " " + str(i+1) + " " + str(j+2) + "\n"

for i in range(h):
  if i == h-1:
    break
  if lists[i][w-1] % 2 == 1:
    lists[i][j] -= 1
    lists[i+1][j] += 1
    count += 1
    # print(i+1, j+1, i+2, j+1)
    operations += str(i+1,) + " " + str(j+1) + " " + str(i+2) + " " + str(j+1) + "\n"

print(count)
print(operations)

Measured memory_bytes: 11104
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

# 加算したリスト
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])
# print(a)
# print(b)

ans, j = 0, m

# 
for i in range(n+1):
    if a[i] > k:
        break

    # bのパイルから何冊読めない？
    while b[j] > k -a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main(){
  int n, y; cin >> n >> y;
  rep(i,n+1){
    rep(j,n-i+1){
      if(10000*i + 5000*j + 1000*(n-i-j) == y){
        cout << i << " " << j << " " << (n-i-j);
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

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

  map<string, int> mp;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;

    mp[s]++;
  }

  int num = 0;
  for(auto p : mp){
    num++;
  }

  cout << num << endl;

  return 0;
}

Measured memory_bytes: 19204
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    string t1 = "",t2;
    rep(i, s.size()){
        if(s[i] != 'x') t1 += s[i];
    }
    t2 = t1;
    reverse(t1.begin(), t1.end());
    if(t1 != t2){
        cout << "-1" << endl;
        return 0;
    }
    vector<int> check;
    rep(i,s.size() + 1){
        int now = 0;
        int id = i;
        while(id < s.size() && s[id] == 'x'){
            id++;
            now++;
        }
        check.push_back(now);
        i = id;
    }
    int ans =  0;
    for(int i = 0; i * 2 < int(check.size()); i++){
        ans += max(check[i], check[check.size() - 1 - i]) - min(check[i], check[check.size() - 1 - i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4196
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
map<ll,ll> cou;
map<ll,ll> visited;

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    rep(i,n){
        cin>>a[i];
        cou[a[i]]++;
    }
    rep(i,n){
        if(visited[a[i]]==1)continue;
        visited[a[i]]=1;
        if(cou[a[i]]>=a[i])ans+=cou[a[i]]-a[i];
        else ans+=cou[a[i]];
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 13056
using System;

namespace SmallLage
{
	class MainClass
	{
		public static void Main ()
		{
			string str = Console.ReadLine ();
			string[]spStr = str.Split(' ');

			int a = int.Parse (spStr[0]);
			int b = int.Parse (spStr[1]);

			if (a < b) {
				Console.WriteLine ("a < b");
			} 
			else if (a > b)
			{
				Console.WriteLine ("a > b");
			}
			else
			{
				Console.WriteLine ("a == b");
			}

		}
	}
}

Measured memory_bytes: 8848
#include <bits/stdc++.h>
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long int lli;
typedef pair<int, int> Pii;
const int INF = 193499;

int W,N,K;
int A[50] , B[50];
int dp[51][5001];

int main(){
    cin >> W;
    int dp[W+1];
    rep(i,W+1) dp[i] = 0;
    dp[0] = 1;
    int a[6];
    a[0] = 100;
    a[1] = 101;
    a[2] = 102;
    a[3] = 103;
    a[4] = 104;
    a[5] = 105;
    rep (i,6){
        rep(j,W-a[i]+1){
            if(dp[j] == 1) dp[j+a[i]] = 1;
        }
    }
    if (dp[W] == 1) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
} 

Measured memory_bytes: 640
#include <iostream>
using namespace std;
#define MAXN 100005
int n;
long long a[MAXN];
long long p = 1, o = 1;
int main () {
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i=0; i<n; i++) {
		if (a[i] > (long long)(1e18/o)) {
			cout << -1 << endl;
			return 0;
		}
		o *= a[i];
		p = o;
	}
	if (o > (long long)1e18) o = -1;
	cout << o << endl;
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ld n;
    ld p = 3.14;
    cin >> n;
    cout << fixed << setprecision(4) << p*n*2.0 << endl;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define INF 2147483647
pair<int,int> data[4000001];
int n,_n;
void init(int n){
  _n=1;
  while(_n<1600000)_n*=2;
}
void update(int i,int x){
  int p=i;
  i+=_n-1;
  data[i].f+=x;
  data[i].s=p+1;
  while(i>0){
    i=(i-1)/2;
    if(data[2*i+1].f==data[2*i+2].f){
      if(data[2*i+1].s<data[2*i+2].s)
        data[i]=data[2*i+1];
      else data[i]=data[2*i+2];
    }
    else if(data[2*i+1].f>data[2*i+2].f)
      data[i]=data[2*i+1];
    else data[i]=data[2*i+2];
  }
}
int main(){
  int q;
  cin>>n>>q;
  init(n);
  while(q--){
    int a,b;
    cin>>a>>b;
    update(a-1,b);
    cout<<data[1].second<<' '<<data[1].first<<endl;
  }
}

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

typedef long long ll;
using namespace std;

int main() {
    int h, n;
    cin >> h >> n;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        sum += a;
    }
    if (h <= sum) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
S = input()
T = input()
LS = len(S)
LT = len(T)
Range = LS-LT+1
cnt = 0
for i in range(Range):
    tmp = 0
    for j in range(LT):
        if S[i+j]==T[j]:
            tmp += 1
    cnt = max(cnt, tmp)
print(LT-cnt)

Measured memory_bytes: 9032
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    X = list(map(int, input().split()))
    x2 = sum([i*i for i in X])
    x = sum(X)
    ret = 100100100
    for p in range(min(X), max(X)+1):
        ret = min(ret, x2 - 2*x*p + N*p*p)
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;


int cnt[3];
int main() {
  vector<string> S(3);
  rep(i,3)cin>>S[i];
  
  int i = 0;
  while(1){
    int next = S[i][cnt[i]]-'a';
    cnt[i]++;
    i = next;
    rep(k,3){
      if(cnt[k]>sz(S[k])){
        char c = 'A'+k;
        cout<<c<<endl;
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $x);

$l = explode(" ", trim(fgets(STDIN)));
$now = 0;
for($i=0; $i<$n; $i++){
    $now += $l[$i];
    if($now > $x){
        echo $i+1;
        exit;
    }
}

echo $n + 1;

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

using namespace std;

int main()
{
  int N,M;
  int X[110000];
  int Y[110000];
  
  cin >> N >> M;
  for(int i=0;i<M;i++) cin>>X[i];
  sort(X,X+M);
  
  for(int i=0;i<M-1;i++) Y[i]=abs(X[i+1]-X[i]);
  sort(Y,Y+M-1);

  int res=0;
  for (int i=0;i<M-N;i++) res+=Y[i];

  cout << res << endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <climits>
#include <functional>

using namespace std;

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

	set<char> cset;
	
	for (auto c : S) {
		if (cset.insert(c).second == false) {
			std::cout << "no" << std::endl;
			return 0;
		}
	}

	std::cout << "yes" << std::endl;

	return 0;
}



Measured memory_bytes: 256
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define N 500005
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,ans,k,a[N],b[N],tot;
int nedge,head[N],to[N*2],Next[N*2],in1[N];
#define V to[i]
void add(int a,int b){
	Next[++nedge]=head[a];head[a]=nedge;to[nedge]=b;in1[b]++;
}
void add_ne(int a,int b){add(a,b);add(b,a);}
struct tre{
	struct t_r{
		int l,r,min;
	}t[N*4];
	void build(int x,int l,int r){
		t[x].l=l;t[x].r=r;t[x].min=n+1;
		if (l==r){
			return;
		}
		int mid=(t[x].l+t[x].r)>>1;
		build(x*2,l,mid);build(x*2+1,mid+1,r);
	}
	void change(int x,int k,int p){
		if (t[x].l==t[x].r){
			t[x].min=p;return;
		}
		int mid=(t[x].l+t[x].r)>>1;
		if (k<=mid) change(x*2,k,p);
		else change(x*2+1,k,p);
		t[x].min=min(t[x*2].min,t[x*2+1].min);
	}
	int query(int x,int l,int r){
		if (t[x].l==l&&t[x].r==r) return t[x].min;
		int mid=(t[x].l+t[x].r)>>1;
		if (r<=mid) return query(x*2,l,r);
		else if (l>mid) return query(x*2+1,l,r);
		else return min(query(x*2,l,mid),query(x*2+1,mid+1,r));
	}
}tr;
int query(int l,int r){
	l=max(l,1);r=min(r,n);if (l>r) return n+1;
	return tr.query(1,l,r);
}
set <int> q;
signed main(){
	n=read();k=read();
	F(i,1,n) a[i]=read(),b[a[i]]=i;
	tr.build(1,1,n);
	D(i,n,1){
		int t=query(b[i]-k+1,b[i]);
		if (t!=n+1) add(b[i],b[t]);
		t=query(b[i],b[i]+k-1);
		if (t!=n+1) add(b[i],b[t]);
		tr.change(1,b[i],i);
	}
	F(i,1,n) if (in1[i]==0) q.insert(i);
	while (!q.empty()){
		int t=*q.be;q.erase(t);a[t]=++tot;
		go(i,t){
			in1[V]--;
			if (in1[V]==0) q.insert(V);
		}
	}
	F(i,1,n) wri(a[i]);put;
	return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

int N;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	vector<ll> A(N);
	FOR(i,0,N){
		cin >> A [i];
	}

	ll ans = 0;
	FOR(i,0,N){
		ans += A [i] / 2;
		A [i] %= 2;
		if(i + 1 < N && A [i] && A [i + 1]){
			ans++;
			A [i]--,A [i + 1]--;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1280
use std::io;

fn read() -> Vec<i32> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read2() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let x: i32 = s.trim().parse().unwrap();
    x
}

fn line(a:Vec<i32>) -> bool{
    let mut b = 0;
    let mut c = 0;

    for i in 0..10{
        if a[i] > b{
            b = a[i];
        }else if a[i] > c{
            c = a[i];
        }else{
            return false;
        }
    }
    true
}

fn main(){
    
    let n = read2();
    for i in 0..n{
        let a_line = read();

        if line(a_line){
            println!("YES");
        }else{
            println!("NO");
        }
    }
}



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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> ans(3);
	ans.at(0) = a+b;
	ans.at(1) = b+c;
	ans.at(2) = c+a;
	int min = 1000;
	for(int i=0; i<3; i++){
    	if(min > ans.at(i)) min = ans.at(i);
    }
	cout << min << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dij geo2 uf

// c++03未検証
using Weight = int;
using Flow = int;
struct Edge {
    int s, d; Weight w; Flow c;
    Edge() {};
    Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
    g[s].push_back(Edge(s, d, w));
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
    addArc(g, a, b, w);
    addArc(g, b, a, w);
}

// c++03未検証
struct UnionFind {
    vector<int> parent;
    int size;
    UnionFind(int n) :parent(n, -1), size(n) {}
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y)return false;
        if (sizeOf(x) < sizeOf(y))swap(x, y);
        parent[x] += parent[y]; parent[y] = x; size--;
        return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
    int sizeOf(int x) { return -parent[root(x)]; }
};

//最小全域木 (Minimum Spanning Tree)
//Kruskal O(|E|log|E|)
//非連結グラフでは最小全域森
// ** 要include uf, graph ** 
pair<Weight, Edges> kruskal(const Graph &g) {
    int n = g.size();
    UnionFind uf(n);
    Edges es;
    for (int i = 0; i < n; i++)
        for (auto &e : g[i])
            es.emplace_back(e);
    sort(es.begin(), es.end());
    Weight total = 0;
    Edges mst;
    for (auto &e : es)
        if (!uf.same(e.s, e.d)) {
            uf.unite(e.s, e.d);
            mst.push_back(e);
            total += e.w;
        }
    return make_pair(total, mst);
}

signed main()
{
    Int(n);
    vp x(n), y(n);
    rep(i, n) {
        cin >> x[i].fir;
        cin >> y[i].fir;
        x[i].sec = i;
        y[i].sec = i;
    }
    sort(all(x));
    sort(all(y));


    Graph g(n);
    rep(i, n-1) {
        addEdge(g, x[i].sec, x[i+1].sec, x[i+1].fir - x[i].fir);
    }
    rep(i, n-1) {
        addEdge(g, y[i].sec, y[i+1].sec, y[i+1].fir - y[i].fir);
    }

    cout << kruskal(g).fir << endl;


    return 0;
}


Measured memory_bytes: 44520
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;

bool isPrime(int n){
    if(n==2)return true;
    for(int i=2;i<n;i++){
        if(n%i==0)return false;
    }
    return true;
}

int main(){
    int n;
    while(cin>>n){
        for(int i=n-1;i>=2;i--){
            if(isPrime(i)){
                cout<<i<<" ";
                break;
            }
        }
        for(int i=n+1;i<100000;i++){
            if(isPrime(i)){
                cout<<i<<endl;
                break;
            }
        }
    }
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    string s;
    cin >> s;
//    int ix = 0;
//    while((ix = (int)s.find("BC", ix)) >= 0){
//        s.replace(ix, 2, "D");
//    }
//    string sub = "";
    ll ans = 0;
    ll a = 0;
    rep(i, s.length()){
        if(s[i] == 'A') a++;
        if(s[i] == 'C') a = 0;
        if(s[i] == 'B' && i != s.length()-1){
            if(s[i+1] == 'C') {
                ans += a;
                i++;
            }
            else a = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int R, G, B, n;
    cin >> R >> G >> B >> n;

    ll cnt = 0;
    reps(r, 0, n){
        if(n - r*R < 0) continue;
        reps(g, 0, n){
            if(n - r*R - g*G >= 0 && (n - r*R - g*G)%B == 0) cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
range = xrange
input = raw_input

S = list(input())

n = len(S)

counter = 0
prefixA = 0
for i in range(n-1):
    if S[i] == 'A':
        prefixA += 1
    elif prefixA and S[i:i+2] == ['B','C']:
        counter += prefixA
        prefixA -= 1
        S[i+1] = 'A'
    else:
        prefixA = 0
print counter


Measured memory_bytes: 42392
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val ps = IntArray(n, { readLine()!!.toInt() - 1 })
  val valueToPosition = IntArray(n, { -1 })
  for (i in 0 until n) {
    valueToPosition[ps[i]] = i
  }

  val dp = IntArray(n)
  dp[0] = 1
  for (k in 1 until n) {
    if (valueToPosition[k] > valueToPosition[k - 1]) {
      dp[k] = dp[k - 1] + 1
    } else {
      dp[k] = 1
    }
  }

  println(n - dp.max()!!)
}


Measured memory_bytes: 43360
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int h,w;
    scanf("%d %d",&h, &w);
    int aaiDeffer[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            scanf("%d", &aaiDeffer[i][j]);
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int x;
            scanf("%d", &x);
            aaiDeffer[i][j] = abs(aaiDeffer[i][j] - x);  //aaiDeffer[i][j]に2整数の差を入れる
        }
    }
    
    vector<vector<vector<char>>> vvviCanValue(h, vector<vector<char>>(w, vector<char>(12801, 0)));  //(i,j)が0~12800の値を取れるか
    vvviCanValue[0][0][aaiDeffer[0][0]] = 1;
    for(int i = 1; i < h; i++){
        for(int j = 0; j < 12801; j++){
            if(vvviCanValue[i - 1][0][j] == 1){
                int x = aaiDeffer[i][0];
                vvviCanValue[i][0][abs(j - x)] = 1;
                vvviCanValue[i][0][j + x] = 1;
            }
        }
    }
  
    for(int i = 1; i < w; i++){
        for(int j = 0; j < 12801; j++){
            if(vvviCanValue[0][i - 1][j] == 1){
                int x = aaiDeffer[0][i];
                vvviCanValue[0][i][abs(j - x)] = 1;
                vvviCanValue[0][i][j + x] = 1;
            }
        }
    }
  
    for(int i = 1; i < h; i++){
        for(int j = 1; j < w; j++){
            for(int k = 0; k < 12801; k++){
                if(vvviCanValue[i - 1][j][k] == 1 || vvviCanValue[i][j - 1][k] == 1){
                    int x = aaiDeffer[i][j];
                    vvviCanValue[i][j][abs(k - x)] = 1;
                    vvviCanValue[i][j][k + x] = 1;
                }
            }
        }
    }
    for(int i = 0; i < 12801; i++){
        if(vvviCanValue[h-1][w-1][i] == 1){
            printf("%d",i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 84368