akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <list>
#include <math.h>
#include <iomanip>

using namespace std;

int main(void) {
    string str;
    cin >> str;

    int year = stoi(str.substr(0,4));
    int month = stoi(str.substr(5,2));
    int day = stoi(str.substr(8,2));

    if(year > 2019) {
        cout << "TBD" << endl;
    }else if(year == 2019) {
        if(month >= 5) {
            cout << "TBD" << endl;
        } else {
            cout << "Heisei" << endl;
        }
    } else {
        cout << "Heisei" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

inline static int read_int() {
    int x = 0, k;
    while ((k = getchar_unlocked() - 'L') >= 0) x = x * 10 + k;
    return x;
}

inline static void put_int(int x) {
    int s = 0;
    char f[6] = {'0', '0', '0', '0', '0', '0'};
    if (!x) {
        putchar_unlocked('0');
        return;
    }
    while (x) {
        f[s++] += x % 10;
        x /= 10;
    }

    while (s--) putchar_unlocked(f[s]);
}

int array[100000];

int main() {
    int flag = 0, lastL = -1, lastR = 0, i = 0, c, diff;

    while ((c = getchar_unlocked() - 'L') >= 0) {
        if (c) {
            if (flag) {
                flag = 0;
                lastL = i - 1;
                diff = i - lastR;
                array[lastR] += (diff - 1) / 2;
                array[lastR + 1] += diff / 2;
            }
        } else {
            if (!flag) {
                flag = 1;
                lastR = i - 1;
                diff = i - lastL;
                array[i - 1] += diff / 2;
                array[i] += (diff - 1) / 2;
            }
        }
        i++;
    }

    diff = i - lastR;
    array[lastR + 1] += diff / 2;
    array[lastR] += (diff - 1) / 2;

    put_int(array[0]);
    for (c = 1; c < i; c++) {
        putchar_unlocked(' ');
        put_int(array[c]);
    }

    putchar_unlocked('\n');
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int a,b,c,d;
	cin >> a>>b>>c>>d;
   string ans;
  if((c-1)/b>(a-1)/d)ans="No";
    else ans="Yes";

    cout << ans << endl;
}

Measured memory_bytes: 3628
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int
var S string

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	S = nextStr()

	var ans, now int
	for i := 0; i < N; i++ {
		if string(S[i]) == "I" {
			now++
			ans = maxInt(ans, now)
		} else {
			now--
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

//std::cout << std::fixed << std::setprecision(10)
constexpr long long MOD = 1000000007;

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (auto& val: A)
    std::cin >> val;
  std::vector<int> B(N, 0);
  for (int i = N; 0 < i; --i)
  {
    int j = i - 1 + i;
    int cnt = 0;
    while (j < N)
    {
      cnt += B[j];
      j += i;
    }
    if (cnt % 2 == 0)
    {
      if (A[i - 1] == 1)
        B[i - 1] = 1;
    }
    else
    {
      if (A[i - 1] == 0)
        B[i - 1] = 1;
    }
  }
  auto M = std::count_if(B.begin(), B.end(), [](auto x) { return x == 1; });
  std::cout << M << "\n";
  for (int i = 0; i < B.size(); ++i)
  {
    if (B[i] == 1)
      std::cout << i + 1 << " ";
  }
  std::cout << std::endl;
  return 0;
}



Measured memory_bytes: 2432
n = int(input())
s = input()

l_dict = {}
r_dict = {}

for c in s:
	r_dict[c] = 0
	l_dict[c] = 0

for c in s:
	r_dict[c] += 1

ans = 0
for c in s:
	l_dict[c] += 1
	r_dict[c] -= 1

	count = 0
	for k, v in l_dict.items():
		if v > 0:
			if r_dict[k] > 0:
				count += 1

	ans = max(ans, count)

print(ans)
	

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		int H = 0;
		double maxTemperature = Double.MAX_VALUE;
		int answer = 0;

		for (int i = 0 ; i < N; i++) {
			H = sc.nextInt();
			if (Math.abs(A - (T - H * 0.006)) < maxTemperature) {
				maxTemperature = Math.abs(A - (T - H * 0.006));
				answer = i + 1;
			}
		}

		System.out.println(answer);
	}
}


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

int main() {
  int N, K; cin >> N >> K;
  vector<int> stick(N);
  for (int i=0; i<N; i++) cin >> stick[i];
  sort(stick.begin(), stick.end(), greater<int>());
  int length=0;
  for (int i=0; i<K; i++) length+=stick[i];
  cout << length << endl;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main{
	def main(args: Array[String]): Unit = {

		val N = StdIn.readLine.toInt

		val result: Int =
			(1 to N).filter( _ % 2 == 1)
				.count( num => diviserNum(num) == 8)
		println(result)
	}
// ↓カリー化
// 属性が異なる時 or 2こめが関数

	// やりたいこと
	// truwVal がbase で何回割り切れるか？　を返す
	// (base = 2,trueVal = 12) => 2
  //	log_2(8)
	def log(base: Int)(trueVal: Int): Int = {
		var i = 0  // 参照透過性  Paas 関数の処理が通った後に副作用があると(例外 )
		var trueVar = trueVal

		// 再帰呼び出しでかけそう
		while( trueVar % base == 0 ) {
			i = i + 1
			trueVar = trueVar / base
		}
		i

		//ループをスカラ的に 末尾最適
		}

	def log2(base: Int)(trueVal: Int): Int ={
		def loop(acc: Int)(base: Int, trueVal: Int): Int = {
			if (trueVal % base == 0) loop(acc + 1)(base, trueVal / base)
			else acc
		}

		loop(0)(base, trueVal)
		// FP in Scala
	}

	def diviserNum(N: Int): Int = {
		val inclusive = 2 to (Math.sqrt(N).toInt + 1)
		var Nvar = N

		val resultList = inclusive.map { num =>
			val result_i = log(num)(Nvar)
			Nvar = Nvar / Math.pow(num.toDouble, result_i.toDouble).toInt
			result_i
		}
		val result =
			resultList.filter(_ > 0).foldLeft(1) { (rs, num) =>
				rs * (num + 1)
			}
		result
	}
}

Measured memory_bytes: 25408
# AtCoder ABC84 D -2017-like NUmber
# 累積和とエラトステネスのふるいを使用

Q = int(input())

# 十分な値の範囲を取っておく
MAX = 101010
A   = [1]*MAX

# 0と1は素数から除外
A[0] = 0
A[1] = 0

# エラトステネスのふるい
# 素数以外の値をふるい落とす
for n in range(2, MAX):
    i = n * 2
    while i < MAX:
        A[i] = 0
        i += n

# 2017に似た数を0から1にする
a = [0]*MAX
for n in range(MAX):
    if n % 2 == 0:
        continue
    if A[n] and A[(n+1)//2]:
        a[n] = 1

# 累積和
S = [0]*(MAX+1)
for n in range(MAX):
    S[n+1] = S[n] + a[n]

# l, rの範囲の総和を求める
B = []
for q in range(Q):
    l, r = map(int, input().split())
    r += 1
    B.append(S[r] - S[l-1])

for b in B:
    print(b)

Measured memory_bytes: 17636
#include<stdio.h>

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

	scanf("%d %d %d", &x, &a, &b);
	
	if (b - a <= 0) {
		printf("delicious\n");
	}
	else if (b - a <= x) {
		printf("safe\n");
	}
	else {
		printf("dangerous\n");
	}

	return 0;

}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    int a, b, c;
    int x=0;
    cin >>a>>b>>c;
    int y=4;
    while(y--){
        if(a>b){
            x=a;
            a=b;
            b=x;
        }
        if(b>c){
            x=c;
            c=b;
            b=x;
        }
    }
    cout << a << " " << b << " " << c << '\n';
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  string s,t;cin>>s>>t;
  
  bool a[26][26] = {0};
  rep(i,s.size()){
    a[s[i] - 'a'][t[i] - 'a'] = true;
  }
  bool ok = true;
  rep(i,26){
    bool tmp = false;
    rep(j,26){
      if(a[i][j]){
        if(tmp)ok = false;
        else tmp = true;
      }
    }
    tmp = false;
    rep(j,26){
      if(a[j][i]){
        if(tmp)ok = false;
        else tmp = true;
      }
    }
  }
  print(ok ? "Yes" : "No");
  return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  ll ans=(100LL*(n-m)+1900LL*m)*round(pow(2LL,m));
  cout<<ans<<endl;
}


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

string S;
vector<uint64_t> SI;
uint64_t searchsp;

int64_t sumPat(vector<uint64_t> &S, uint64_t F){
  uint64_t e = 1;
  uint64_t sum = 0;
  for(uint64_t i = 0; i < S.size(); i++){
    sum += S.at(i) * e;
    if(((F >> i) & 1) == 1)
      e = 1;
    else
      e *= 10;
  }

  return sum;

}

int main(){

  uint64_t sum=0;

  cin >> S;
  searchsp = pow(2,S.size()-1);

  for(uint64_t i=0;i < S.size();i++){
    SI.push_back((uint64_t)S.at(i) - 48);
  }
  reverse(SI.begin(),SI.end());
  for(uint64_t i=0;i < searchsp;i++){
    sum += sumPat(SI,i);
  }

  cout << sum << endl;

}


Measured memory_bytes: 4040
// https://atcoder.jp/contests/abc114/tasks/abc114_c

#include <algorithm>
#include <cmath>
#include <iostream>
// #include <string>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

int len = 0, cnt = 0, n;

void rege(string s) {
    // 3, 5, 7が含まれている
    if (s.find("3") != std::string::npos && s.find("5") != std::string::npos &&
        s.find("7") != std::string::npos && stoi(s) <= n) {
        cnt++;
    }
    if ((int)s.size() < len) {
        rege(s + "3");
        rege(s + "5");
        rege(s + "7");
    }

    return;
}

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

    s = to_string(n);
    len = s.size();
    rege("");

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3696
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int div=N/100;
  int rem=N-100*div;
  if(rem%5==0){
    if(rem/5<=div){
      cout<<1;
    }else{
      cout<<0;
    }
  }else{
    if((rem/5+1)<=div){
      cout<<1;
    }else{
      cout<<0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
long long int k;
	cin>>s;
	cin>>k;
	int l=s.length();
	if(s[0]!='1')
	   cout<<s[0]<<endl;
	else
	{
		long long int i=0;
		int count=0;
		while(i<l && s[i]=='1')
		{
			count++;
			i++;
		}
//		cout<<k<<"\n";
//		cout<<i<<"\n";
//		cout<<count<<"\n";
		
		if(k<=i)
		   cout<<"1"<<endl;
		else
		   cout<<s[i]<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int ans;
int main(){
	int n;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='A'){
			if(s[i+1]=='B'){
				if(s[i+2]=='C'){
					ans++;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#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 all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int a, b, c;

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

    if(a + b >= c) puts("Yes");
    else puts("No");

}


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

public class AtCoderA
{
    static void Main()
    {
        int n;
        int k;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            k = int.Parse(words[1]);
        }

        int answer = 1;
        while (true)
        {
            if (n >= k)
            {
                n = n / k;
                answer++;
            }
            else
            {
                break;
            }
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   string s;
   cin >> s;
   if( s == "Sunny") cout << "Cloudy" << endl;
   else if( s == "Cloudy") cout << "Rainy" << endl;
   else if( s == "Rainy") cout << "Sunny" << endl;


   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const ll inf=100000000000000;
struct edge{
	int to,cost;
};
int main() {
	string x;
	cin>>x;
	int n=x.length();
	int t=0,s=0;
	for(int i=0;i<n;++i){
		if(x[i]=='S'){
			s++;
		}else{
			if(s>0){
				s--;
			}else{
				t++;
			}
		}
	}
	cout<<t+s<<endl;

	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main()
{
  short rate_before,rate_after;
  int price_before,i,a,b,max;
  int n,m,p,q,r;

  // i,p = ?¨???????????????????                                                       
  // n,r = ????¨???????????????????                                                     
  // a,b = ????¨???????????????????                                                     

  while(1){
    max = 0;
    scanf("%hd %hd %d",&rate_before,&rate_after,&price_before);

    if(rate_before == 0 && rate_after == 0 && price_before == 0){
      break;
    }

    for(i = 1;i <= price_before/2;i++){
      n = i * (100+rate_before) / 100;
      m = price_before - n;
      p = m * 100 / (100+rate_before);

      while(1){
          p++;
          q = p * (100+rate_before) / 100;
          if(n + q != price_before){
              p--;
              break;
          }
      }

      q = p * (100+rate_before) / 100;

      if(n + q == price_before){
          a = i * (100+rate_after) / 100;
          b = p * (100+rate_after) / 100;
          if(a+b > max){
              max = a + b;
          }
      }
    }
    printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a, b, c;
    cin >> a >> b>> c;
    swap(a,b);
    swap(a,c);
    cout<< a <<" "<< b<<" " << c <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b, k;
	cin >> a >> b >> k;
	--k;
	vector<int> candy;
	for( int i = 1; i <= 100; ++i ){
		if( a % i == 0 && b % i == 0 ){
			candy.push_back(i);
		}
	}
	reverse( candy.begin(), candy.end() );
	cout << candy.at(k) << endl;
	return 0;
}

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

int main(){
	int n; cin >> n; std::vector<std::string> s(n);
	for(int i = 0; i < n; i++) cin >> s[i];
	std::string w; cin >> w;
	
	std::vector<std::string> a, b;
	for(int i = 0; i < n; i++){
		std::string A = s[i], B = s[i];
		
		for(int j = 0; j < A.size(); j++) if(A[j] == '?') A[j] = 'a';
		for(int j = 0; j < B.size(); j++) if(B[j] == '?') B[j] = 'z';
		a.push_back(A); b.push_back(B);
	}
	a.push_back(w); b.push_back(w);
	sort(begin(a), end(a)); sort(begin(b), end(b));
	
	int A, B;
	for(int i = 0; i < a.size(); i++){
		if(a[i] == w){
			A = i + 1;
			break;
		}
	}
	
	for(int i = b.size() - 1; i >= 0; i--){
		if(b[i] == w){
			B = i + 1;
			break;
		}
	}
	
	for(int i = std::min(A, B); i <= std::max(A, B); i++) cout << i << (i == std::max(A, B) ? '\n' : ' ');
	return 0;
}


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

int main() {
    char S[10];
    int len = 0;
    int ans = 0;

    scanf("%s", S);

    for (int i = 0; S[i] != '\0'; ++i) {
        if((S[i]=='A')||(S[i]=='T')||(S[i]=='C')||(S[i])=='G') {
            len++;
            if(len > ans) ans = len;
        } else {
            len = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin >> a.at(i);
  rep(i,n) a.at(i)--;
  int x=-1;
  int y=-2;
  int z=-3;
  int v=-4;
//  rep(i,n) cout << a.at(i) << endl;
  int count = 0;
  int num = 0;
      num = a.at(0);
  count ++;
  b.at(num)++;
  for(;;){
    if(num == 1) break;
    num = a.at(num);
    b.at(num)++;
    if(b.at(num)>=2){
      count=-1;
      break;
    }
    count ++;
  }
  cout << count << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

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

    int x;
    cin >> x;
    long long resa = 121, resb = 121;
    for(long long a = 1; a <= 120; a++){
        for(long long b = 0; b <= 120; b++){
            long long a5 = a * a * a * a * a;
            long long b5 = b * b * b * b * b;
            
            if(a5 - b5 == x){
                resa = a; resb = b;
                break;
            }
            if(a5 + b5 == x){
                resa = a; resb = -b;
                break;
            }
        }
        if(resa != 121)
            break;
    }
    cout << resa << " " << resb << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
const int inf = 1e9;
const int maxn = 1e5 + 10;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a, b;
	cin >> a >> b;
	if (b >= a)
		cout << "unsafe";
	else cout << "safe";
	return 0;
}

Measured memory_bytes: 3564
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
#n = ip()                                     #入力整数1つ
#a,b,c= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
a.pop(6)
a.pop(5)
a.pop(2)
s = sum(a)
for i in range(4):
    if i != 1 and a[i]%2: s-=1
if s+3==sum(a):s = sum(a)
if s+2==sum(a) and a[0] and a[2] and a[3] > 3:s = sum(a)-1
print(s)

Measured memory_bytes: 22712
import sys
from collections import Counter

n, m, x = map(int, input().split())
a_list = list(map(int, input().split()))
math_list = []

for i in range(n):
    if i in a_list:
        math_list.append(1)
    else:
        math_list.append(0)
#print(n, x, a_list, math_list)
print(min(sum(math_list[0:x]), sum(math_list[x+1::])))


Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int n, q;
int a[1000000];
int ans[1000000];
int main() {
    cin >> n >> q;
    a[1] = 1;
    for(int i=1; i<n; i++) {
        int x, y;
        cin >> x >> y;
        a[y] = x;
        ans[i] = 0;
    }
    for(int i=1; i<=q; i++) {
        int x, y;
        cin >> x >> y;
        ans[x] += y;
    }
    for (int i=2; i<=n; i++)
        ans[i] += ans[a[i]];
    for (int i=1; i<=n; i++)
        cout << ans[i] << " ";
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <map>
#include <vector>

using namespace std;

typedef pair<string, string> P;

bool ans[100];
vector<P> vec;
string in;

//1. P("!", vowel)
//2. P(cons, vowel)
//3. P(cons+"y", vowel)
//4.soku P(cons, "@")
//5.hatsu P("n'", "#")
//6.tyou P(vowel, "$")

bool isVowel(char c){
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') return true;
  return false;
}

bool isVLCons(char c){
  if(c == 'k' || c == 's' || c == 't' || c == 'h' || c == 'p') return true;
  return false;
}

main(){
  while(cin >> in && in != "#"){
    vec.clear();
    char a , b, c;
    a = b = c = 0;
    for(int i=0;i<in.size();i++){
      string str;
      str += in[i];
      if(i+1 == in.size() && in[i] == 'n') vec.push_back(P("n", "#"));
      if(isVowel(in[i])){
        if(!a && !b){
          if(c == in[i]) vec.push_back(P(str, "$"));
          else vec.push_back(P("", str));
          a = 0; b = 0; c = in[i];
        }
        else if(a && !b){
          string A;
          A += a;
          vec.push_back(P(A, str));
          a = 0; b = 0; c = in[i];
        }
        else if(a && b){
          string A;
          A += a;
          A += b;
          vec.push_back(P(A, str));
          a = 0; b = 0; c = in[i];
        }
      }else{
        if(in[i] == '\'' ){
          vec.push_back(P("n\'", "#"));
          a = 0; b = 0; c = 0;
        }
        else if(!a){
          a = in[i];
        }
        else if(a && a == 'n' && in[i] != 'y'){
          vec.push_back(P("n", "#"));
          a = in[i]; b = 0; c = 0;
        }
        else if(a && a != 'y' && a != 'w' && in[i] == 'y'){
          b = in[i];
        }
        else if(a && a == in[i]){
          vec.push_back(P(str, "@"));
        }
      }
    }
    //vec.push_back(P("k", "#"));
    fill(ans, ans+100, false);
    for(int i=0;i<vec.size();i++){
      char c = vec[i].second[0];
      if(!(c == '@' || c == '#' || c == '$')){
        if(c == 'i' || c == 'u'){
          if(isVLCons(vec[i].first[0]) && (i+1 == vec.size() || isVLCons(vec[i+1].first[0]))) ans[i] = true;
        }
        if(i > 0 && (c == 'a' || c == 'o')){
          if(isVLCons(vec[i-1].first[0]) && isVLCons(vec[i].first[0])){
            char c2 = vec[i-1].second[0];
            if(!(c == '@' || c == '#' || c == '$') && c == c2) ans[i-1] = true;
          }
        }
      }
    }
    for(int i=0;i<vec.size();i++){
      //cout << vec[i].first << ' ' << vec[i].second << ' ' << ans[i] << endl;
    }
    int p = 0;
    for(int i=1;i<vec.size();i++){
      char c = vec[i].second[0];
      if(ans[p] && ans[i]) ans[i] = false;
      if(c != '@' && c != '#' && c != '$') p = i;
    }
    for(int i=0;i<vec.size();i++){
      char c = vec[i].second[0];
      cout << vec[i].first;
      if(!(c == '@' || c == '#' || c == '$')){
        if(ans[i]) cout << "(" << vec[i].second << ")";
        else cout << vec[i].second;
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    long x = scan.nextLong();
    long tmp = 100;
    long cnt = 0;

    while (true) {
      cnt++;
      tmp += tmp * 1 / 100;
      if (tmp >= x) {
        System.out.println(cnt);
        return;
      }
    }

  }

}

Measured memory_bytes: 35848
###############################################################################

from bisect import bisect_left as binl

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


###############################################################################


def main():
    x, y, z, k = intin()
    alist = intina()
    blist = intina()
    clist = intina()

    ablist = []
    for a in alist:
        for b in blist:
            ablist.append(a + b)

    ablist.sort(reverse=True)

    abclist = []
    for ab in ablist[:(k+1)]:
        for c in clist:
            abclist.append(ab + c)

    abclist.sort(reverse=True)

    for i in range(k):
        print(abclist[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 147004
#include <iostream>
 
using namespace std;
 
const int G[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
 
int main () {
    int x, y;
    cin >> x >> y;
 
    if (G[x] == G[y]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
S = input().rstrip()

ans = 1000

l = len(S)
for i in range(l-2):
    ans = min(ans, abs(753 - int(S[i:i+3])))

print(ans)

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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;

ll root(ll x, vector<ll> &par){
    if(par[x]==0) return x;
    return root(par[x],par);
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n,m;
    cin >> n >> m;
    ll a,b,max=1;
    vector<ll> par(n+1,0),num(n+1,1);
    rep(i,m){
        cin >> a >> b;
        ll ra = root(a,par);
        ll rb = root(b,par);
        if(ra != rb){
            par[b]=ra;
            par[rb]=ra;
            num[ra]+=num[rb];
            if(num[ra]>max) max = num[par[b]];
        }
    }
    print(max);
    return 0;
}

Measured memory_bytes: 6360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<int>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define mem(a) (memset(a,0,sizeof(a)))
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 ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=5005,mod=1e9+7;
int f[N][N],g[N][N],s[N][N],sum;
int a[2];
inline void add(int &a,int b){
	a+=b; if(a>=mod)a-=mod;
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read(),x=read(),y=read();
	if(x>y)swap(x,y);
	f[0][0]=1;
	For(i,0,n){
		f[i][y]=g[i][y]=0;
		if(i>=x){
			For(j,0,i)if(i>=x){
				g[i][j]=s[i-x][i-j];
				//cout<<i<<" "<<j<<" "<<s[i-x][i-j]<<" "<<sum<<endl;
				add(sum,mod-f[i-x][j]);
			}
		}
		g[i][0]=sum;
		For(j,0,min(i,y-1)){
			//cout<<f[i][j]<<" "<<g[i][j]<<" "<<i<<" "<<j<<" "<<endl;
			add(f[i+1][j+1],g[i][j]);
			add(f[i+1][j+1],f[i][j]);
			if(i)s[i][i-j]=s[i-1][i-j];
			add(s[i][i-j],f[i][j]);
			add(sum,f[i][j]);
		}
	}
	ll ans=1;
	For(i,1,n)ans=ans*2%mod;
	For(i,0,y-1)ans=(ans-f[n][i]-g[n][i]+mod*2)%mod;
	cout<<ans<<endl;
}
/*
dp[i][j]->dp[i+...][0]
不妨令 1 全不满
满的0全改为1 
11111100111110011111
...10011100010001
*/

Measured memory_bytes: 225756
#pragma GCC optimize ("Ofast")
#include"bits/stdc++.h"
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << "  ";
    __f(comma + 1, args...);
}

#define ll long long
#define pii pair<int,int>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i)
#define int long long int
#define all(n) n.begin(),n.end()
#define mem(n,i) memset(n,i,sizeof n)
#define em(a) emplace_back(a)
#define pb(a) push_back(a)
#define srep(it,vv) for(auto &it : vv)
#define prep(it,vv) for(auto it : vv)
//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));

typedef vector<int> vii;
typedef vector<string> vss;
/*

*/
signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, cap; cin >> n >> cap;
    vector<int>wei(n + 5);
    vector<int>profit(n + 5);

    rep(i, n) cin >> wei[i] >> profit[i];

    vector<vector<int>>dp(n + 5, vector<int>(100000 + 5, INT_MAX));

    dp[n + 1][0] = 0;

    for (int i = n; i >= 1; i--)
    {
        for (int j = 0; j <= 1e5; j++)
        {
            if (j - profit[i] >= 0) dp[i][j] = min(dp[i + 1][j], wei[i] + dp[i + 1][j - profit[i]]);
            else dp[i][j] = dp[i + 1][j];
        }
    }
    int ans = 0;
    for (int i = 0; i <= 1e5; i++) if (dp[1][i] <= cap) ans = i;

    cout << ans << endll;

}

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

typedef long long LL;
const int N = 2e5 + 50;

int n, a[N];
LL fix[N], L;

inline LL calc(int l) {
  if (l == n) return 0;
  if (l == n - 1) return L - (a[n] - a[n - 1]);
  if ((n - l + 1) % 2 == 0) {
    int p = (n - l + 1) / 2;
    LL res = fix[n] - fix[n - p + 1];
    res = L * (p - 1) - res;
    res += fix[l + p - 1] - fix[l];
    res *= 2;
    return res + (L - a[n - p + 1]) + a[l];
  } else {
    int p = (n - l + 1) / 2;
    LL res = fix[n] - fix[n - p];
    res = L * p - res;
    res += fix[l + p - 1] - fix[l];
    res *= 2;
    return res + a[l] + a[l + p];
  }
}

int main() {
  scanf("%lld%d", &L, &n);
  for (int i = 1; i <= n; i ++) {
    scanf("%d", &a[i]);
    fix[i] = fix[i - 1] + a[i];
  }
  fix[n + 1] = fix[n];
  LL ans = 0;
  for (int i = 1; i <= n; i ++)
    ans = max(ans, a[i] + calc(i));
  reverse(a + 1, a + n + 1);
  for (int i = 1; i <= n; i ++) {
    a[i] = L - a[i];
    fix[i] = fix[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i ++)
    ans = max(ans, a[i] + calc(i));
  printf("%lld\n", ans);
  return 0;
}

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

char s[15];

int main()
{
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> s;
    int len = strlen(s);
    int minn = 1e9+7;
    for(int i = 0; i < len - 2; ++i){
        int x = 100*(s[i] - '0') + 10*(s[i+1] - '0') + (s[i+2] - '0');
        minn = min(minn, abs(x-753));
    }
    cout << minn << endl;
    return 0;
}


Measured memory_bytes: 256
n,a,b,c,d = (x-1 for x in map(int,input().split()))
n+=1
s = input()

if "##" in s[b:d+1]:
	# print('b-dで岩２つ')
	ans = 'No'
else:
	if "##" in s[a:c+1]:
		# print('a-cで岩２つ')
		ans = 'No'
	else:#邪魔な岩は無し
		if c>d: #ふぬけを飛び越える必要がある場合
			#ふぬけ君を飛び超えるために3マス以上連続で空いてる場所を探してあげる
			if "..." in s[b-1:d+2]:
				# print('空きマス３つある')
				ans = 'Yes'
			else:#飛び越えるスペースが無かった
				# print(s[b:])
				# print('空きマス３つない・・・')
				ans = 'No'
		else:#ふぬけ、すぬけの順に動かせばいい場合、岩はもう見た
			# print('ふぬけ→すぬけ　OK')
			ans = 'Yes'

print(ans)

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

using namespace std;

using ll = long long;

int N, A, B, C;
std::vector<int> l;

ll dfs(const ll index, const ll a, const ll b, const ll c) {
    if (index == N) {
        if (a != 0 && b != 0 && c != 0) {
            return std::abs(a - A) + std::abs(b - B) + std::abs(c - C) - 30;
        } else {
            return 1e9;
        }
    }

    std::vector<ll> result;
    result.emplace_back(dfs(index + 1, a, b, c));
    result.emplace_back(dfs(index + 1, a + l[index], b, c) + 10);
    result.emplace_back(dfs(index + 1, a, b + l[index], c) + 10);
    result.emplace_back(dfs(index + 1, a, b, c + l[index]) + 10);

    return *std::min_element(result.cbegin(), result.cend());
}

int main() {

    cin >> N >> A >> B >> C;

    l.resize(N);
    for (int i = 0; i < N; ++i) {
        cin >> l[i];
    }

    cout << dfs(0, 0, 0, 0) << endl;

    return 0;
};

Measured memory_bytes: 256
A, B, C = [input() for i in range(3)]
turn = 'a'
a_position = b_position = c_position = 0
while True:
    if turn == 'a':
        if a_position == len(A):
            print('A')
            break
        else:
            turn = A[a_position]
            a_position += 1
    if turn == 'b':
        if b_position == len(B):
            print('B')
            break
        else:
            turn = B[b_position]
            b_position += 1
    if turn == 'c':
        if c_position == len(C):
            print('C')
            break
        else:
            turn = C[c_position]
            c_position += 1


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, a;
    cin>>n;
    vector<int> vec;
    vector<int>::iterator it;
    for(int i = 0; i < n; ++i){
        cin>>a;
        it = vec.begin();
        if(i % 2 != 0){
            vec.insert(it, a);
        }
        else{
            vec.push_back(a);
        }
    }
    if(n % 2 != 0){
        reverse(vec.begin(), vec.end());
    }
    for(auto x : vec){
        cout<<x<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  map<string, ll> ns;
  string s;
  for(int i = 0; i < N; ++i) {
    cin >> s;
    sort(s.begin(), s.end());
    ns[s]++;
  }
  ll ans = 0;
  for(auto n : ns) {
    ans += (n.second * (n.second - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11136
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

map<int, pair<int, int>> m;

pair<ll, ll> dfs(int pos, vector<int>& used, vector<vector<int>>& g, vector<string>& S) {
	if (used[pos])return { 0,0 };
	used[pos] = 1;
	pair<ll, ll> tmp = { 0,0 };
	if (S[m[pos].first][m[pos].second] == '.')tmp.first += 1;
	else tmp.second += 1;
	for (int i = 0; i < g[pos].size(); i++) {
		if (used[g[pos][i]])continue;
		auto a = dfs(g[pos][i], used, g, S);
		tmp.first += a.first;
		tmp.second += a.second;
	}
	return tmp;
}
int main() {
	io_init;
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	vector<vector<int>> g(H * W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			m[i * W + j] = { i,j };
			if (i != 0) {
				if (S[i][j] != S[i - 1][j]) {
					g[i * W + j].push_back((i - 1) * W + j);
					g[(i - 1) * W + j].push_back(i * W + j);
				}
			}
			if (i != H-1) {
				if (S[i][j] != S[i + 1][j]) {
					g[i * W + j].push_back((i + 1) * W + j);
					g[(i + 1) * W + j].push_back(i * W + j);
				}
			}
			if (j != 0) {
				if (S[i][j] != S[i][j - 1]) {
					g[i * W + j].push_back(i * W + j - 1);
					g[i * W + j - 1].push_back(i * W + j);
				}
			}
			if (j != W-1) {
				if (S[i][j] != S[i][j + 1]) {
					g[i * W + j].push_back(i * W + j + 1);
					g[i * W + j + 1].push_back(i * W + j);
				}
			}
		}
	}
	ll ans = 0;
	vector<int> used(H * W, 0);
	for (int i = 0; i < H * W; i++) {
		auto a = dfs(i, used, g, S);
		ans += a.first * a.second;
	}
	cout << ans << endl;
}


Measured memory_bytes: 37376
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
int R, C, N, X1, Y1, X2, Y2;
vector<pair<int, int>>v;
set<int>st;

bool f(int x, int y) {
	if (x == 0 || x == R || y == 0 || y == C)return true;
	else return false;
}
pair<int, int> ff(){
	int a, b;
	if (Y1 == 0) {
		a = X1;
	}
	else if(Y1 == C){
		a = R + C + R - X1;
	}
	else if (X1 == 0) {
		a = R + C + R + C - Y1;
	}
	else if (X1 == R) {
		a = R + Y1;
	}
	if (Y2 == 0) {
		b = X2;
	}
	else if(Y2 == C){
		b = R + C + R - X2;
	}
	else if (X2 == 0) {
		b = R + C + R + C - Y2;
	}
	else if (X2 == R) {
		b = R + Y2;
	}
	
	if (a > b)swap(a, b);
	return mkp(a, b);
}
int main() {
	cin >> R >> C >> N;
	for (int i = 0; i < N; ++i) {
		cin >> X1 >> Y1 >> X2 >> Y2;
		if (f(X1, Y1) && f(X2, Y2)) {
			v.push_back(ff());
		}
	}
	sort(v.begin(), v.end());
	st.insert(-1);
	for (int i = 0; i != v.size(); ++i) {
		auto it = st.insert(v[i].second).first;
		--it;
		if (*it > v[i].first) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 5748
import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    n = int(input())

    nums = list(map(int, input().split()))

    ans = 'Yes'

    for x in reversed(range(1, len(nums))):
        if nums[x-1] - nums[x] >= 2:
            ans = 'No'

        elif nums[x-1] - nums[x] == 1:
            nums[x-1] -= 1

        else:
            continue

    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 14508
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	int n,m; cin>>n>>m;
	vi vec(n);
	rep(i,0,n)cin>>vec[i];
	vector<bool> ans(n);
	rep(i,0,m){
		int a,b; cin>>a>>b;
		--a; --b;
		if(vec[a]==vec[b]){
			ans[a]=1;
			ans[b]=1;
		}
		else if(vec[a]<vec[b]){
			ans[a]=1;
		}
		else ans[b]=1;
	}
	ll cnt=0;
	rep(i,0,n)if(!ans[i])cnt++;
	cout<<cnt<<endl;
	
}

Measured memory_bytes: 3796
#include <stdio.h>

int main(int argc, char *argv[])
{
	int now,cnt = 0;
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	now = a;
	while (1)
	{
		if(now>b){
			printf("%d\n",cnt);
			break;
		}
		if(c % now == 0){
			cnt ++;
		}
		now ++;
	}

	return 0;
}




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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

typedef long long ll;

#define MAX_N 10000

struct Edge {
    int to;
    int weight;
    Edge(int t, int w)
        : to(t)
        , weight(w)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

vector<int> dx = { 1, 0, -1, 0 };
vector<int> dy = { 0, 1, 0, -1 };
typedef pair<int, int> P;

bool G[10][10];

int main()
{
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        G[a][b] = G[b][a] = true;
    }

    // Permutation
    vector<int> ord(N);
    for (int i = 0; i < N; i++)
        ord[i] = i;

    // try permutation
    int res = 0;
    do {
        if (ord[0] != 0) // スタートは0限定
            break;

        bool ok = true;
        for (int i = 0; i + 1 < N; i++) {
            int from = ord[i];
            int to = ord[i + 1];
            if (!G[from][to])
                ok = false;
        }
        if (ok)
            res++;
    } while (next_permutation(ord.begin(), ord.end()));

    cout << res << endl;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

string s;

int main()
{
	cin>>s;
	if(s[0]!='A')
	{
		puts("WA");
		return 0;
	}
	if(s.size()>=3)
	{
		if(s[1]=='C'||isupper(s[1]))
		{
			puts("WA");
			return 0;
		}
		int flag1=0,flag2=0;
		for(int i=2;i<s.size()-1;i++)
		{
			if(isupper(s[i])&&s[i]=='C'&&flag2==0)
			{
				flag2=1;
			}
			else
			{
				if(!islower(s[i]))flag1=1;
			}
		}
		if(isupper(s[s.size()-1]))
		{
			puts("WA");
			return 0;
		}
		if(flag1)
		{
			puts("WA");
		}
		else
		{
			if(!flag2)
			{
				puts("WA");
			}
			else
			{
				puts("AC");
			}
		}
	}
	else
	{
		puts("WA");
	}
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
inline ll pow2(const int n) { return 1ll << n; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;
// 1. 問題よくよめえええええええええええええええええええええええええ
// 2. intオーバーフロー << * + あたり
// 3. 落ち着け

int gcd(int a, int b) {
    if (a > b) swap(a, b);
    if (b % a == 0) return a;
    return gcd(b % a, a);
}

int N;
vi A;

int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) {
        cin >> A[i];
    }

    int ans = A[0];
    rep(i, 1, N) {
        ans = gcd(ans, A[i]);
    }
    write(ans);
}

Measured memory_bytes: 640