akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3


def solve(N: int, S: str):
    answer = ""
    for s in S:
        answer += chr(65 + (ord(s) - 65 + N) % 26)
    return answer


def main():
    N = int(input())
    S = input().strip()
    answer = solve(N, S)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9100
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
count = 0
for i in range(n):
  if a[i] <= b[i]:
    count += a[i]
    b[i] -= a[i]
    if a[i+1] <= b[i]:
      count += a[i+1]
      a[i+1] = 0
    else:
      count += b[i]
      a[i+1] -= b[i]
  else:
    count += b[i]

print(count)

Measured memory_bytes: 18624
#include<iostream>
#define K 1000000
using namespace std;
int h[K],w[K],n,m,i,j,p[1500],k;
int main(){
  while(1){
    for(i=1;i<K;i++)h[i]=0,w[i]=0;
    cin>>n>>m;if(n==0&&m==0)break;
    for(i=0;i<n;i++){
      cin>>p[i];
      for(j=i,k=0;j>=0;j--,k+=p[j])h[p[i]+k]++;
    }
    for(i=0;i<m;i++){
      cin>>p[i];
      for(j=i,k=0;j>=0;j--,k+=p[j])w[p[i]+k]++;
    }
    n=0;
    for(i=1;i<K;i++)n+=h[i]*w[i];
    cout<<n<<endl;
  }
  return 0;
}

Measured memory_bytes: 8976
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int  A , B , R ,temp , x ,ans;
  cin >> A >> B ;  
  ans = 0;
  temp = 0;

 for (int i = A; i < B+1 ; i++) { //Aから Bまでループ
     temp = i;                    //新しい数字をtempに格納
     R = 0;                       //ｘ、R初期化
     x = 0;
   for (int j = 0; j < 5 ; j++){   //5桁分ループ開始
     x = temp % 10;               //1の桁を格納
     R = R*10 + x ;               //反対にしていく  
     temp = temp / 10;            //tempを一桁減らす
   }  
   if (i == R){                   //回文なら
     ans++;                        
   }
 }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int a,b;

int main()
{
    scanf("%d%d",&a,&b);
    if (a==b) printf("%d",a+b);
    else printf("%d",max(a,b)*2-1);
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 128
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int pos[MAXN];
ll n, x, m, z[MAXN];
vector<ll> w;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> x >> m;
    pos[x] = 1;
    ll now = x;

    int idx = 1, cycleLen = 0, start = 0;
    z[1] = x;
    while (1) {
        idx++;
        now = now * now % m;
        if (pos[now] == 0) {
            pos[now] = idx;
            z[idx] = now;
        } else {
            cycleLen = idx - pos[now];
            start = pos[now];
            idx--;
            break;
        }
    }
    ll res = 0;
    if (n < start) {
        FOR(i,1,n) res += z[i];
        cout << res;
    }
    else {
        FOR(i,1,start-1) res += z[i];
        FOR(i,start,idx) w.push_back(z[i]);
        
        FOR(i,1,SZ(w)-1) w[i] += w[i-1];
        n -= start-1;
        
        ll numCycle = n / cycleLen;
        res += numCycle * w[SZ(w)-1];
        n %= cycleLen;
        if (n > 0) res += w[n-1];
        
        cout << res;
    }
    return 0;
}


Measured memory_bytes: 4568
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray();
        for (int i = 0; i < a.Length; i++)
        {
            if (a[i] != (n - 1) - ((i / 2) * 2))
            {
                Console.WriteLine(0);
                return;
            }
        }

        Console.WriteLine(power(2, n / 2));
    }

    
    static int power(int n, int m)
    {
        const int mod = 1000000007;
        long pow = n;
        long res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res = (res * pow) % mod;
            pow = (pow * pow) % mod;
            m >>= 1;
        }
        return (int)res;
    }
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    char s[3][123] = {
        "Sunny","Cloudy","Rainy"
    };

    char t[1312];
    Scs(t);

    int i = 13;
    if( t[0] == 'S' ) i = 0;
    if( t[0] == 'C' ) i = 1;
    if( t[0] == 'R' ) i = -1;

    printf ("%s\n", s[++i] );

    return 0;
}





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

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

    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

    int count = 0;
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0 && A.at(i) % 2 == 1)
        {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3624
N = int(input())
if N == 3:
    print(*[2, 5, 63])
elif N == 4:
    print(*[2, 5, 20, 63])
elif N == 5:
    print(*[2, 5, 20, 30, 63])
else:
    ans = []
    k = 0
    for i in range(2, 30001):
        if i % 2 == 0 or i % 3 == 0:
            ans.append(i)
            k += 1
            if k == N:
                break

    if sum(ans) % 6 == 0:
        print(*ans)
    elif sum(ans) % 6 == 2:
        for j in range(N):
            if ans[j] == 8:
                ans.pop(j)
                break
        ans.append(30000)
        print(*ans)
    elif sum(ans) % 6 == 3:
        for j in range(N):
            if ans[j] == 9:
                ans.pop(j)
                break
        ans.append(30000)
        print(*ans)
    else:
        for j in range(N):
            if ans[j] == 9:
                ans.pop(j)
                break
        ans.append(29998)
        print(*ans)


Measured memory_bytes: 4556
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

int main() {
    int A, B, C; cin >> A  >> B >> C;
    if (A == B) cout << C << endl;
    else if (B == C) cout << A << endl;
    else cout << B << endl;
}



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

typedef pair<ll,ll> P;
const ll MO = 1000000007;

int main(){
    ll a,b,c,k;
    cin >> a >> b >>c >> k;
    ll ans = 0;
    if(k>=a){
        ans+=a;
        k-=a;
    }else{
        ans+=k;
        cout<<ans << endl;
        return 0;
    }
    if(k>=b){
        k-=b;
    }else{
        cout<<ans << endl;
        return 0;
    }
    ans-=k;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long

int Q, T, F;
char C;
bool R;
string S;
deque<char> D;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> S;
	for (char c : S) D.push_back(c);
	cin >> Q;
	while (Q--) {
		cin >> T;
		if (T == 1) R = !R;
		else {
			cin >> F >> C;
			F--;
			F ^= R;
			if (F == 0) D.push_front(C);
			else D.push_back(C);
		}
	}
	if (!R) for (char c : D) cout << c;
	else for (int i = D.size() - 1; i >= 0; i--) cout << D[i];
	cout << '\n';
}


Measured memory_bytes: 976
/*********************************************************************************/
/* 0）test(i): i番目のフラグの状態がONの場合は1、OFFの場合は0を出力する          */
/* 1）set(i):  指定されたマスクが表す部分のフラグをまとめてONにする              */
/* 2）clear(i):指定されたマスクが表す部分のフラグをまとめてOFFにする             */
/* 3）flip(i): 指定されたマスクが表す部分のフラグをまとめて反転する              */
/* 4）all:     指定されたマスクが表す部分の全てのフラグがONになっている場合1、
		なっていない場合0を出力する                                      */
/* 5）any:     指定されたマスクが表す部分のいずれかのフラグがONになっている場合1、
		なっていない場合0を出力する                                      */
/* 6）none:    指定されたマスクが表す部分の全てのフラグがOFFになっている場合1、
		なっていない場合0を出力する                                      */
/* 7）count:   指定されたマスクが表す部分のONになっているフラグの数を出力する    */
/* 8）val:     指定されたマスクが表す部分の整数値を出力する                      */
/*********************************************************************************/

#include<stdio.h>

#define BY_8 64

typedef struct order{
	int cmd;
	int num;
}Order;

typedef struct mask{
	int num;
	int bit[65];
}Mask;

/*10⇒2変換*/
void di2bi(unsigned long x, int* b){
	int i;
	
	for(i=32-1; i>=0; i--){
		b[i] = (x>>i)&1;
	}
}
/*2⇒10変換*/
unsigned long bi2di(unsigned long *bi_x, Mask *Mask){
	int i;
	unsigned long di_x = 0;
	
	for(i=0; i<Mask->num; i++){
		/*マスク構造体変数に入っている"指定位置"のビットを"指定値"ぶんだけシフトする*/
		di_x = di_x + (bi_x[ Mask->bit[i] ] << Mask->bit[i]);
	}
	return di_x;
}
int Flag_Chk(unsigned long *bi_x, Mask *Mask){
	int i, flag;
	flag = 0;
	
	for(i=0; i<(Mask->num); i++){
		if(bi_x[ Mask->bit[i] ] == 1) flag +=1;
	}
	return flag;
}
	

void Cmd_Exe(unsigned long *bi_x, int cmd, int num_ord, Mask* Mask){
	int i, flag;
	flag = Flag_Chk(bi_x, Mask);
	switch (cmd){
		case 0:
			if(bi_x[num_ord] == 1){
				printf("1\n");
			}else{
				printf("0\n");
			}
			break;
		case 1:
			for(i=0; i<(Mask->num); i++)
				bi_x[ Mask->bit[i] ] = 1;
			break;
		case 2:
			for(i=0; i<(Mask->num); i++)
				bi_x[ Mask->bit[i] ] = 0;
			break;
		case 3:
			for(i=0; i<(Mask->num); i++)
				bi_x[ Mask->bit[i] ] = bi_x[ Mask->bit[i] ]^1;
			break;
		case 4:
			if(flag == Mask->num){
				printf("1\n");
			}else{
				printf("0\n");
			}
			break;
		case 5:
			if(flag > 0){
				printf("1\n");
			}else{
				printf("0\n");
			}
			break;
		case 6:
			if(flag == 0){
				printf("1\n");
			}else{
				printf("0\n");
			}
			break;
		case 7:
			printf("%d\n", flag);
			break;
		case 8:
			printf("%lu\n", bi2di(bi_x, Mask));
			break;
		default:
			break;
	}
}

int main(){
	int i, j, k, num_msk, num_ord;
	Order Ord[200001];
	Mask Mask[11];
	unsigned long x;
	unsigned long bi_x[BY_8] = {0};
	
	/*マスク設定のコンソール入力*/
	scanf("%d", &num_msk);
	for(i=0; i<num_msk; i++){
		scanf("%d", &Mask[i].num);
		for(j=0; j<Mask[i].num; j++){
			scanf("%d", &Mask[i].bit[j]);
		}
	}
	
	/*ビット操作指定のコンソール入力*/
	scanf("%d", &num_ord);
	for(i=0; i<num_ord; i++){
		scanf("%d %d", &Ord[i].cmd, &Ord[i].num);
		getchar();
	}
	
	for(i=0; i<num_ord; i++){
		/*ビット配列, 命令番号, マスクNoの指定, 引数3で指定した番号のマスクのアドレス*/
		Cmd_Exe(bi_x, Ord[i].cmd, Ord[i].num, &Mask[ Ord[i].num ]);
	}
	
	return 0;
}


Measured memory_bytes: 3336
from collections import deque
n, k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10 ** 9 + 7

p = []
m = []
for i in a:
    if i >= 0:p.append(i)
    elif i < 0:m.append(i)

p.sort(reverse=True)
m.sort()
res = 1
if n == k:
    for i in a:
        res = (res * i) %mod
    print(res)
    exit()
    
if len(p) == 0 and k % 2 == 1:
    for i in range(k):
        res = (res * m[-(i + 1)]) %mod
    print(res)

else:
    p_ind = 0
    m_ind = 0
    while k:
        if k == 1:
            res = (res * p[p_ind]) % mod
            break
        
        temp = p[p_ind] * p[p_ind + 1] if p_ind + 1 < len(p) else 0
        temp1 = m[m_ind] * m[m_ind + 1] if m_ind + 1 < len(m) else 0
        if temp > temp1:
            res = (res * p[p_ind]) %mod
            p_ind += 1
            k -= 1
        else:
            res = (res * temp1) %mod
            m_ind += 2
            k -= 2
    print(res)

Measured memory_bytes: 32392
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();
    static final int M = 1_000_000_007;

    public static void main(String[] args){
        int n = in.i();
        int m = in.i();
        int[] x = in.ii(n);
        int[] y = in.ii(m);

        long sx = f(n, x);
        long sy = f(m, y);

        long ans = (M + sx * sy % M) % M;
        out.println(ans);
    }

    static long f(int n, int[] x) {
        long sx = 0;
        long t = 0;
        for (int i = n - 2; i >= 0; i--) {
            t = (t + x[i + 1]) % M;
            sx = (sx + t - (long)(n - 1 - i) * x[i]) % M;
        }
        return sx;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = read(cbuf, 0, cbuf.length);
            } catch (IOException e) {}
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                back();
                break;
            }
        }
    }

    char[] s(final int N) {
        skip();
        char[] s = new char[N];
        for (int i = 0; i < s.length; i++) {
            s[i] = next();
        }
        return s;
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 36528
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
//UnionFind

const int maxn=100000;

int main(){
    int x,a,b;
    cin >> x>>a>>b;
    cout << (x-a)%b<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N; cin>>N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin>>A[i];
    bool ok = true;
    sort(A.begin(), A.end());
    ll tmp = 1;
    for (int i = 0; i < N; ++i) {
        if(N%2==0){
            if(A[i]!=tmp){ok = false; break;}
            if(i%2!=0) tmp+=2;
        }else{
            if(i==0){
                if(A[i]!=0){ok = false; break; }
            }else{
                if(A[i]!=(i+1)/2*2) {ok = false; break;}
            }
        }
    }

    if(ok){
        ll ans = 1;
        for (int i = 0; i < N/2; ++i) ans = ans*2 % MOD;
        cout<<ans<<endl;
    }else cout<<0<<endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int H,W,h, w;
	cin >> H >> W;
	cin >> h >> w;
	cout << H * W - ((H*w + W * h) - w * h) << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var s = bufio.NewScanner(os.Stdin)

func Scan() string {
	s.Scan()
	return s.Text()
}

func main() {
	fmt.Println(p())
}

func ScanInt() int {
	a, err := strconv.Atoi(Scan())
	if err != nil {
		return 10
	}
	return a
}

func p() int {
	s.Split(bufio.ScanWords)
	a, b := ScanInt(), ScanInt()
	if a > 9 || b > 9 {
		return -1
	}
	return a * b
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        switch (d) {
            case 22:
                System.out.println("Christmas Eve Eve Eve");
                break;
            case 23:
                System.out.println("Christmas Eve Eve");
                break;
            case 24:
                System.out.println("Christmas Eve");
                break;
            case 25:
                System.out.println("Christmas");
                break;
            default:
                break;
        }
    }
}

Measured memory_bytes: 20692
#include<stdio.h>  
    main(){  
      int n,ba=0,ban=0;  
      int hito[10]={0};  
      char mei;  
      int a,b,c,d,e;  
      while(1){  
        scanf("%d",&n);  
        if(n==0)break;  
        for(a=0;a<100;a++){  
          scanf(" %c",&mei);  
          if(mei=='M'){  
        hito[ban]=hito[ban]+1;  
          }  
          else if(mei=='S'){  
        ba=ba+hito[ban]+1;  
        hito[ban]=0;  
          }  
          else if(mei=='L'){  
        hito[ban]=hito[ban]+ba+1;  
        ba=0;  
          }  
          ban=ban+1;  
          if(ban==n){  
        ban=0;  
          }  
        }  
        for(a=0;a<n;a++){  
          for(b=n-1;b>0;b--){  
        if(hito[b]<hito[b-1]){  
          c=hito[b];  
          hito[b]=hito[b-1];  
          hito[b-1]=c;  
        }  
          }  
        }  
        for(a=0;a<n;a++){  
          printf("%d ",hito[a]);  
        }  
        printf("%d\n",ba);  
        ba=0;  
        ban=0;  
        for(a=0;a<10;a++){  
          hito[a]=0;  
        }  
      }  
      return 0;  
    }  

Measured memory_bytes: 600
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int N;
    string S;
    cin >> N >> S;

    string judge = "";
    int cnt = 0;
    for (int i = 0; i <= S.length()-3; i++) {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
            cnt++;
        }
    }
    cout << cnt;

    return 0;
}

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

//const double PI=3.141592653589793238;
int main(void)
{
    long long N, M, K;

    cin >> N >> M >> K;

    int i,j;
    long long _a, _b;
    int ans=0;

    long long a[N+1], b[M+1];

    a[0]=b[0]=0;

    for(i=1;i<N+1;i++)
    {
        cin >> _a;
        a[i] = a[i-1] + _a;
    } 
    for(j=1;j<M+1;j++)
    {
        cin >> _b;
        b[j] = b[j-1] + _b;
    }
    j=M;

    for(i=0;i<N+1;i++)
    {
        if(a[i]>K) break;
 
        while(b[j] + a[i] > K) j-=1;
 
        ans = max(ans, i+j);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6724
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] C = new int[4];

        for (int i = 0; i < N; i++) {
            String s = sc.next();
            switch (s) {
                case "AC":
                    C[0] = C[0] + 1;
                    break;
                case "WA":
                    C[1] = C[1] + 1;
                    break;
                case "TLE":
                    C[2] = C[2] + 1;
                    break;
                default:
                    C[3] = C[3] + 1;
                    break;
            }
        }

        System.out.println("AC x " + C[0]);
        System.out.println("WA x " + C[1]);
        System.out.println("TLE x " + C[2]);
        System.out.println("RE x " + C[3]);
    }
}

Measured memory_bytes: 49240
import java.util.PriorityQueue;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] a = new int[3 * N];
    long[] s = new long[N + 1];
    long[] t = new long[N + 1];
    for (int i = 0; i < 3 * N; i++) a[i] = scanner.nextInt();

    PriorityQueue<Integer> left = new PriorityQueue<>();
    for (int i = 0; i < N; i++) {
      left.add(a[i]);
      s[0] += a[i];
    }
    for (int i = 0; i < N; i++) {
      s[i + 1] = s[i];
      if (a[N + i] > left.peek()) {
        int r = left.poll();
        left.add(a[N + i]);
        s[i + 1] += a[N + i] - r;
      }
    }

    PriorityQueue<Integer> right = new PriorityQueue<>((o1, o2) -> o2 - o1);
    for (int i = 2 * N; i < 3 * N; i++) {
      right.add(a[i]);
      t[N] += a[i];
    }
    for (int i = N - 1; i >= 0; i--) {
      t[i] = t[i + 1];
      if (a[N + i] < right.peek()) {
        int r = right.poll();
        right.add(a[N + i]);
        t[i] += a[N + i] - r;
      }
    }

    long max = Long.MIN_VALUE;
    for (int i = 0; i <= N; i++) max = Math.max(max, s[i] - t[i]);
    System.out.println(max);
  }
}


Measured memory_bytes: 96492
n,k=map(int,raw_input().split())
w=[input() for _ in range(n)]
l=max(w)
r=sum(w)
while l<r:
    m=(l+r)/2
    s=c=0
    for i in w:
        s+=i
        if s>m:s=i;c+=1
    if c<k:r=m
    else:l=m+1
print l

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

int main(){
  int P, Q, R;
  cin >> P >> Q >> R;
  
  int route[3];
  
  route[0] = P + Q;
  route[1] = P + R;
  route[2] = Q + R;
  
  sort(begin(route), end(route));
  
  cout << route[0];
}

Measured memory_bytes: 256
d,g=map(int,input().split())
l=[list(map(int,input().split())) for i in range(d)]
ans=float("INF")
for i in range(2**d):
    allgreen={j for j in range(d) if (i>>j)%2}
    su=sum(l[k][0]*100*(k+1)+l[k][1] for k in allgreen)
    now=sum(l[k][0] for k in allgreen)
#    print(now)
    for k in range(d-1,-1,-1):
        if su>=g:break
        p,c=l[k]
        if k in allgreen:continue
        else:
            jk=min(-(-g+su)//((k+1)*100),p-1)
            now+=jk
            su+=jk*100*(k+1)
#            print(i,jk)
    if su>=g:ans=min(ans,now)
print(ans)

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<int>a(n,1);
	vector<bool>v(n,false); v.front()=true;
	for(int i=0;i<m;++i){
		int x,y; cin>>x>>y;
		--a.at(x-1),++a.at(y-1);
		if(v.at(x-1)==true)v.at(y-1)=true;
		if(a.at(x-1)==0)v.at(x-1)=false;
	}
	cout<<count(v.begin(),v.end(),true)<<"\n"s;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B;
  cin>>A>>B;
  ll ans=A+B;
  if(A*B>ans) {
ans=A*B;
  }
if(A-B>ans) {
  ans=A-B;
}
  cout<<ans<<endl;
}

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

#define int long long

string s;
int k;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s >> k >> s;
	k--;
	s[k] += - 'A' + 'a';
	cout << s;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
graph = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a,b =  map(int,input().split())
    graph[a-1][b-1] = 1
    graph[b-1][a-1] = 1

count = 0
visited = [0]*n
def dfs(initial,graph,visited):
    global count
    all_visited = True
    visited[initial] = 1
    for i in visited:
        if i == 0:
            all_visited = False 
            
    if all_visited == True:
        count += 1
        return 0
    
    for i in range(n):
        if graph[initial][i] ==1:
            if visited[i] == 0:
                visited[i] = 1
                dfs(i,graph  ,visited)
                visited[i] = 0
    return count


print(dfs(0 ,graph , visited ))

Measured memory_bytes: 3064
l, r = map(int, input().split())

if r - l >= 2019:
    print(0)
    exit()
    
l %= 2019
r %= 2019

if l >= r:
    print(0)
    exit()

ans = 2019

for i in range(l, r):
    for j in range(i+1, r+1):
        ans = min(ans, (i*j)%2019)

print(ans)

Measured memory_bytes: 3064
//#pragma GCC optimize("03", "unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(i,n) for(i=0;i<n;i++)
#define FORn(i,j,n) for(i=j;i<n;i++)
#define pb push_back
#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define vli vector<lli>
#define vi vector<int>
#define vs vector<string>
#define vprint(v) for(auto t:v)cout<<t<<" "
#define endl "\n"

typedef long long int lli;
typedef long int li;

const lli mod=1000000007;
const lli limit=1000000;

using namespace std;

void fc(lli &x)
    {
        bool neg=false;
        register char c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    fast()
    lli n,q,t;
    lli temp,temp1,temp2,temp3;
    lli i,j,k;
    cin>>k>>n;
    lli arr[2*n];
    FOR(i,n)cin>>arr[i];
    FOR(i,n){
        arr[n+i]=arr[i]-k;
    }
    sort(arr,arr+2*n);
    temp=0;
    FOR(i,n-1){temp+=abs(arr[i+1]-arr[i]);}
    temp1=abs(temp);
    for(i=n-1;i<2*n-1;i++){
        temp+=abs(arr[i+1]-arr[i])-abs(arr[i-n+2]-arr[i-n+1]);
        temp1=min(temp1,temp);
    }
    cout<<temp1<<endl;

 
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(),(x).end()
#define lowbit(x) x&-x
#define pb push_back
#define ls (id<<1)
#define rs (id<<1|1)
#define Rint register int
#define UNI(x) sort(ALL(x)),x.resize(unique(ALL(x))-x.begin())
#define GETPOS(c,x) (lower_bound(ALL(c),x)-c.begin())
#define LEN(x) strlen(x)
#define MS0(x) memset((x),0,sizeof((x)))
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<pii> Vpii;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(ll &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const ll &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
const int MAXN=1e6+10,MAXM=4e6+10;
const int INF=INT_MAX,SINF=0x3f3f3f3f;
const ll llINF=LLONG_MAX;
const int MOD=1e9+7,mod=998244353;
const int inv2=5e8+4;
const int Lim=1<<20;

int n,k,c;
char s[MAXN];
int cnt[MAXN];
Vi ans;

void solve()
{
    R(n,k,c,s);
    int res=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='o')
        {
            cnt[i]++;
            i=i+c;
            res++;
        }
    }
    if(res>k)return;
    for(int i=n-1;i>-1;i--)
    {
        if(s[i]=='o')
        {
            cnt[i]++;
            i=i-c;
            res++;
        }
    }
    for(int i=0;i<n;i++)if(cnt[i]==2)W(i+1);
}

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define gcd __gcd
#define pcount __builtin_popcount
#define pcountll __builtin_popcountll
#define nxtperm next_permutation
#define int ll
//primitive roots: 998244353 - 3; 7340033 - 5
//#pragma 03
//#pragma GCC target ("sse4.2")

const ll mod = 1000000007;		const double PI = acos(-1.);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef complex<double> cd;

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
	{
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const
	{
        static const uint64_t kawaii = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + kawaii);
    }
};

int const maxn = 200; 
int n, W, v[maxn], w[maxn], dp[maxn][100005]; // minimum weight to reach value j for first i items. 
int mx, INTLMAO = 1e18; 

signed main()
{
//	freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
// 	fast_cin();
	cin >> n >> W;
	for(int i=1;i<=n;i++) cin >> w[i] >> v[i], mx += v[i];  
	for(int i=1;i<=mx;i++) dp[0][i] = 1e18; 
	for(int i=1;i<=n;i++) 
	{
		for(int j=1;j<=mx;j++)
		{
			dp[i][j] = min(dp[i-1][j], (j >= v[i] ? dp[i-1][j - v[i]] + w[i] : INTLMAO)); 
		}
	}
	for(int i=mx;i>=0;i--) 
	{
		if(dp[n][i] <= W)
		{
			cout << i; 
			return 0; 
		} 
	}
}

/*
	Test input:
*/


Measured memory_bytes: 80128
#!/usr/bin/ruby
s=gets.chomp+'$'
n=s.size
suff=n.times.sort_by{|i|s[i..-1]}
bwt=suff.map{|e|s[(e-1)%n]}
sorted=n.times.map{|i|[bwt[i],i]}.sort
#gets.to_i.times{
	q=gets.chomp.reverse
	start=0
	stop=n
	if q.size.times{|i|
		start,stop=[
			(0...n).bsearch{|j|(sorted[j]<=>[q[i],start]) >= 0}||n,
			(0...n).bsearch{|j|(sorted[j]<=>[q[i],stop]) >= 0}||n,
		]
		break if start==stop
	} then
		puts (start...stop).map{|i|suff[i]}.sort
		#p 1
	else
		#p 0
	end
#}

Measured memory_bytes: 8884
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int ans,n,h,w;

main(){
	cin>>n>>h>>w;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		if(h<=a&&w<=b)ans++;
	}
	dans;
}



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

int main(void){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<int>b(n);
    for(int i=0;i<n;i++){
        b[i]=a[i]-i;
    }
    sort(b.begin(),b.end());
    int cent;
    if(n%2){
        cent=b[(n+1)/2-1];
    }else{
        cent=b[(n+1)/2-1];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(b[i]-cent);
    }
    cout<<ans<<endl;

}

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

int main() {
  int N,ans;
  cin>> N;
  vector<int> a(N);
  for (int i =0;i<N;i++){
    cin>> a.at(i);
  }
  while(true){
    bool exist_odd =false;
    for(int i =0; i <N ; i++){
      if (a.at(i) %2 ==1){
        exist_odd =true;
      }
    }
    if(exist_odd){
      break;
    }
    for (int i=0; i<N; i++){
      a[i] /=2;
    }
    ans ++ ;
  }
  cout <<ans<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int a, b;
    cin >> a >> b;
    cout << 6-(a+b) << endl;
    return 0;
}




Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = input()
if len(set(n[0:3])) == 1 or len(set(n[1:4])) == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 10448
#include<stdio.h>
#include<iostream>
using namespace std;
 
int main()
{
 int a, b;
 cin>>a>>b;
 a%=2;
 b%=2;
 a=(a*b)%2;
 if(a==1)
 {
  cout<<"Odd";
 }
 else
{
 cout<<"Even";
}
cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 500005
#define ll long long
using namespace std;

int n;
string s[MAX];
map<string, int> mp;
vector<string> v;

int main()
{
    cin >> n;
    int mx = 0;
    for(int i = 1; i <= n; i++){
        cin >> s[i];
        mp[s[i]]++;
        mx = max(mx, mp[s[i]]);
    }
    for(int i = 1; i <= n; i++){
        if(mp[s[i]] == mx){
            v.push_back(s[i]);
            mp[s[i]] = -1;
        }
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < v.size(); i++){
        cout << v[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 30836
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m,t;
  cin >> n >> m >> t;
  int d[t+2];
  mem(d);
  rep(i,n) {
    int x;
    R x;
    d[max(0,x-m)]++;
    d[min(t+1,x+m)]--;
  }
  rep(i,t) d[i+1]+=d[i];
  int cnt=0;
  rep(i,t) if(!d[i]) cnt++;
  pr(cnt);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3252
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    string s = "";
    cin >> s;
    ll ans = 0;
    for (int i=1; i<s.size(); i++) {
        if (s.at(i) != s.at(i-1)) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Data {
	public int p, y, index;
	public String num;

	public Data(int p0, int y0, int index0){
		p = p0;
		y = y0;
		index = index0;
	}
}

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] count = new int[n+1];
		ArrayList<Data> data = new ArrayList<>(m);
		
		for(int i = 0;i < m;i++){
			int p = sc.nextInt();
			int y = sc.nextInt();
			
			data.add(new Data(p, y, i));
		}
		data.sort((a,b)-> a.y-b.y);
		
		for(int i = 0;i < m;i++){
			Data nowData = data.get(i);
			int p = nowData.p;
			
			count[p]++;
			
			nowData.num = String.format("%06d", p) + String.format("%06d", count[p]);
		}
		data.sort((a,b)-> a.index-b.index);
		
		PrintWriter out = new PrintWriter(System.out);
		
		for(int i = 0;i < m;i++){
			out.println(data.get(i).num);
		}
		out.flush();
		
		
		sc.close();
	}
}


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

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

ll n,cnt,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
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,ans;
bool fl;
struct edge{int to,cost;};

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

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

    cin>>s;
    rep(i,Size(s)){
        if(s[i]=='B'){
            if(Size(ans)==0)continue;
            ans.erase(Size(ans)-1);
        }
        else{
            ans+=s[i];
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
if N == 1:
    print('Yes')
    exit()
for i in range(N-1):
    if H[i] == H[i+1]:
        continue
    elif H[i] < H[i+1]:
        H[i+1] -= 1
    else:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 14252
import numpy as np
N,Q = map(int,input().split())
S = np.array(list('_' + input()), dtype='U2')
A = (S == 'A')
C = (S == 'C')
AC = (A[:-1] & C[1:])
AC_cum = AC.cumsum()

for _ in range(Q):
    L,R = map(int,input().split())
    print(AC_cum[R-1] - AC_cum[L-1])

Measured memory_bytes: 17468
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,sum=0;
    scanf("%d%d",&a,&b);
    if(a>b)sum=a+(a-1);
    if(b>a)sum=b+(b-1);
    else if(a==b){
        sum=a+b;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra()
{
    priority_queue<pair<int, int> > PQ;
    int color[MAX];
    int d[MAX];
    for (int i = 0; i < n; i++)
    {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    PQ.push(make_pair(0, 0));
    color[0] = GRAY;

    while( !PQ.empty())
    {
        pair<int, int> f = PQ.top();
        PQ.pop();
        int u = f.second;

        color[u] = BLACK;

        if (d[u] < f.first * (-1)) continue;

        for (int j = 0; j < adj[u].size(); j++)
        {
            int v = adj[u][j].first;
            if (color[v] == BLACK) continue;
            if( d[v] > d[u] + adj[u][j].second)
            {
                d[v] = d[u] + adj[u][j].second;
                PQ.push(make_pair(d[v]*(-1), v));
                color[v] = GRAY;
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main()
{
    int k, u, v, c;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 8072
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {

    
    // ここから入力
    
    int n,cnt = 0;
    cin >> n;
    bool can = false;
    REP(i,n){
        int a,b;
        cin >> a >> b;
        if(a == b) cnt++;
        else cnt = 0;
        
        if(cnt >= 3) can = true;
        
    }
    
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;

    
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >>S;
  
  if(S.at(0)!=S.at(1)&&S.at(1)!=S.at(2)&&S.at(0)!=S.at(2)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 506;
int n, m;
char s[N][N], t[N][N], a[N][N], c;

int main() {
	cin >> n >> m;
    for (int i = 1; i <= n; i += 2)
        for (int j = 1; j <= m; j++)
            s[i][j] = '#';
    for (int i = 2; i <= n; i += 2)
        for (int j = 1; j <= m; j++)
            s[i][j] = '.';
    for (int i = 2; i <= n; i += 2)
        for (int j = 1; j <= m; j++)
            t[i][j] = '#';
    for (int i = 1; i <= n; i += 2)
        for (int j = 1; j <= m; j++)
            t[i][j] = '.';
    for (int i = 1; i <= n; i++)
    	for (int j = 1; j <= m; j++) {
    		cin >> c;
    		if (c == '#') s[i][j] = t[i][j] = '#';
		}
	for (int i = 1; i <= n; i++) s[i][1] = '#', t[i][1] = '.';
	for (int i = 1; i <= n; i++) s[i][m] = '.', t[i][m] = '#';
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++)
			cout << s[i][j];
		cout << endl;
	}
	cout << endl;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++)
			cout << t[i][j];
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 1280
/*
	DATE:		2020-03-02 14:26:46
	NAME:		
	PROBLEM:	ABC157C
*/
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 10;

int s[MAXN + 7];
int c[MAXN + 7];

void get_digits(int x, vector<int> &digits) {
  if (x == 0) {
    digits.push_back(x);
    return;
  }
  while (x > 0) {
    digits.insert(digits.begin(), x % 10);
    x /= 10;
  }
}

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

  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &s[i], &c[i]);
  }

  int start = 0;
  int end = 9;

  if (n == 2) {
    start = 10;
    end = 99;
  }
  else if (n == 3) {
    start = 100;
    end = 999;
  }

  for (int number = start; number <= end; number++) {
    vector<int> digits;
    get_digits(number, digits);

    bool fl = true;

    for (int i = 1; i <= m; i++) {
      if (s[i] > (int) digits.size()) {
        fl = false;
      }
      else if (digits[s[i] - 1] != c[i]) {
        fl = false;
      }
    }

    if (fl) {
      printf("%d\n", number);
      return 0;
    }
  }

  printf("-1\n");

  return 0;
}

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

static const int MAX = 100005;

vector<int> G[MAX];
vector<int> topo;
vector<int> used(MAX, false);

void dfs(int s) {
  for (int i = 0; i < G[s].size(); i++) {
    if (used.at(G[s][i]) == false) dfs(G[s][i]);
  }
  topo.emplace_back(s);
  used.at(s) = true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    G[x].emplace_back(y);
  }
  
  for (int i = 0; i < n; i++) {
    if (used.at(i) == false) dfs(i);
  }
  
  vector<int> ans(n, 0);
  for (int i = 0; i < n; i++) {
    int now = topo.at(i), keep = 0;
    for (int j = 0; j < G[now].size(); j++) {
      keep = max(keep, ans.at(G[now][j]) + 1);
    }
    ans.at(now) = keep;
  }
  
  int ans2 = 0;
  for (int i = 0; i < n; i++) ans2 = max(ans2, ans.at(i));
  cout << ans2 << '\n';
}

Measured memory_bytes: 8440