akhauriyash/Code-Regression huggingface dataset:
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string S;
    cin >> S;

    string ans = "";
    REP(i, SIZE(S))
    {
        FOR(j, 1, SIZE(S) - i)
        {
            string sub = S.substr(i, j);
            bool is_acgt = true;
            REP(k, SIZE(sub))
            {
                if (sub[k] != 'A' && sub[k] != 'C' && sub[k] != 'G' && sub[k] != 'T')
                {
                    is_acgt = false;
                    break;
                }
            }

            if (is_acgt && SIZE(ans) <= SIZE(sub))
            {
                ans = sub;
            }
        }
    }

    cout << SIZE(ans) << endl;

    return 0;
}


Measured memory_bytes: 3668
import numpy as np
A = []
for i in range(3):
  A.append(list(map(int,input().split())))

N = int(input())
B = []
for i in range(N):
  B.append(int(input()))

for i,a in enumerate(A):
  for j,x in enumerate(a):
    if x in B:
      A[i][j] = 0

def bingo(x):
  if sum(x) == 0:
    print('Yes')
    exit()

for x in A:
  bingo(x)

AT = [list(x) for x in zip(*A)]
for x in AT:
  bingo(x)

AD = [A[i][i] for i in range(3)]
bingo(AD)

AD = [A[i][2-i] for i in range(3)]
bingo(AD)

print('No')


Measured memory_bytes: 12512
#define ONLINE_JUDGE
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <iterator>
#include <map>
#include <set>
#ifndef ONLINE_JUDGE
#include <prettyprint/prettyprint.hpp>
#endif

#define FOR(i, n) for(int i = 0; i < n; ++i)
#define TEST int T; std::cin >> T; while(T--)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vull = std::vector<ull>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	ifstream fin("in.txt");
	ofstream fout("out.txt");
	auto cinbuf = cin.rdbuf(fin.rdbuf());    // save and redirect
	auto coutbuf = cout.rdbuf(fout.rdbuf()); // save and redirect
#endif	
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i] >> c[i];
	}
	// The start can be any of the three states.
	int ans = 0;
	auto get = [&](int p, int i) {
		if(p == 0) return a[i];
		if(p == 1) return b[i];
		return c[i];
	};
	for(int start = 0; start < 3; ++start) {
		int prev = start;
		vector<int[3]> dp(n);
		dp[0][0] = -1;
		dp[0][1] = -1;
		dp[0][2] = -1;
		dp[0][start] = get(start, 0);
		for(int i = 1; i < n; ++i) {
			dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + get(0, i);
			dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + get(1, i);
			dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + get(2, i);
		}
		ans = max(ans, dp.back()[0]);
		ans = max(ans, dp.back()[1]);
		ans = max(ans, dp.back()[2]);
	}
	cout << ans << endl;
#ifndef ONLINE_JUDGE
	cin.rdbuf(cinbuf);    // restore
	cout.rdbuf(coutbuf); // restore
#endif	
}


Measured memory_bytes: 2668
A = list(input()) + ["x"]
B = list(input()) + ["y"]
C = list(input()) + ["z"]

d = "a"

while True:
    if d == "a":
        d = A[0]
        A = A[1:]
    elif d == "b":
        d = B[0]
        B = B[1:]
    elif d == "c":
        d = C[0]
        C = C[1:]
    elif d == "x":
        print("A")
        exit()
    elif d == "y":
        print("B")
        exit()
    elif d == "z":
        print("C")
        exit()

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

d = {}

max = 0

for _ in range(N):
    S = input()
    if S in d:
        d[S] = d[S] + 1
        if max < d[S]:
            max = d[S]
        continue
    d[S] = 1
    if max < d[S]:
        max = d[S]

ans = []

for key in d:
    if d[key]==max:
        ans.append(key)

ans.sort()
for a in ans:
    print(a)

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

int main(){
  int a, b;
  
  cin >> a >> b;
  if ((a+b)%2){
    cout << (a+b)/2 + 1;
  }
  else{
    cout << (a+b)/2;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef pair<int,int> P;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define lowbit(x) (x&-x)
const ll INF=0x3f3f3f3f;
const double EPS=1e-7;
const int N=3e5+10;
const ll mod=1e9+7;
const ll MOD=998244353;
inline ll read()  
{  ll f=1,x=0;char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
   return x*f;
}
ll n,ans,k,keep;
ll a[N],b[N],p[N],c[N];
void dfs(ll fa,ll now,ll sum)
{  b[keep]=max(b[keep-1],sum);
   a[keep++]=sum;
   if(now==fa)return ;
   dfs(fa,p[now],sum+c[p[now]]);
}
int main()
{  n=read(),k=read();
   ans=-9999999999999;
   b[0]=-9999999999999;
   for(int i=1;i<=n;i++)p[i]=read();
   for(int i=1;i<=n;i++)c[i]=read(),ans=max(ans,c[i]);
   for(int i=1;i<=n;i++)
   {  keep=1;
      dfs(i,p[i],c[p[i]]);
      keep--;
      ll ma=min(keep,k);
      for(int j=1;j<=ma;j++)
      {  ll temp=b[j];
         if(a[keep]>0)temp+=(k-j)/keep*a[keep];
         ans=max(ans,temp);
      }
   }
   printf("%lld",ans);
}

Measured memory_bytes: 3872
# AOJ 1135: Ohgas' Fortune
# Python3 2018.7.14 bal4u

for cno in range(int(input())):
	a0, y, n = int(input()), int(input()), int(input())
	ans = 0
	for i in range(n):
		buf = list(input().split())
		k, r, f = int(buf[0]), float(buf[1]), int(buf[2])
		a = a0
		if k:
			for j in range(y):
				b = (int)(a*r)
				a += b-f
		else:
			c = 0
			for j in range(y):
				b = (int)(a*r)
				a -= f
				c += b
			a += c
		ans = max(ans, a)
	print(ans)



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

int main() {
    int N;
    cin >> N;
    vector<long long> X(N), Y(N), H(N);
    long long sample_x, sample_y, sample_h;
    for (int i = 0; i < N; i++) {
        cin >> X[i] >> Y[i] >> H[i];
        if (H[i] > 0) {
            sample_x = X[i];
            sample_y = Y[i];
            sample_h = H[i];
        }
    }

    for (int x = 0; x <= 100; x++) {
        for (int y = 0; y <= 100; y++) {
            long long height = abs(sample_x - x) + abs(sample_y - y) + sample_h;

            bool check = true;
            if (height < 1) check = false;
            for (int i = 0; i < N; i++) {
                long long h = max(height - abs(X[i] - x) - abs(Y[i] - y), 0LL);
                if (h != H[i]) check = false;
            }

            if (check) {
                cout << x << " " << y << " " << height << endl;
                return 0;
            }
        }
    }
}

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

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

  ll N; cin >> N;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  for (ll i = 0; i < N - 1; i++) {
    if (A[i] == A[i + 1]) {
      cout << "NO" << '\n';
      return 0;
    }
  }
  cout << "YES" << '\n';
  return 0;
}

Measured memory_bytes: 1792
from itertools import permutations

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph._shortest_path import floyd_warshall


def solve():
    N, M, R = map(int, input().split())
    r = list(map(lambda x: int(x)-1, input().split()))
    dist = [[0 for _ in range(N)] for _ in range(N)]
    for _ in range(M):
        A, B, C = map(int, input().split())
        dist[A-1][B-1] = C
        dist[B-1][A-1] = C
    fw = floyd_warshall(csr_matrix(dist))
    
    ans = 10**12
    for visit in permutations(r, R):
        m_sum = 0
        for i in range(R-1):
            m_sum += fw[visit[i]][visit[i+1]]
        ans = min(ans, m_sum)
    print(int(ans))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 16248
# coding:UTF-8
import sys

def pow_r(x, n):
    if n == 0:
        return 1
    if n % 2 == 0:
        return pow_r(x ** 2, n //2)
    else:
        return x * pow_r(x ** 2, (n - 1) // 2)

if __name__ == '__main__':
    # ------ 入力 ------#
    # 1行入力
    n = int(input())    # 数字
    # a = input()     # 文字列
    # a = list(map(int, input().split()))     # スペース区切り連続数字
    # a = input().split()     # スペース区切り連続文字列
    # a = [int(c) for c in input()]   # 数字→単数字リスト変換

    # 定数行入力
    # x = 5
    # a = [int(input()) for _ in range(x)] # 数字
    # a = [input() for _ in range(x)] # 文字
    # a = [list(map(int, input().split())) for _ in range(x)]     # スペース区切り連続数字(行列)
    # a = [input().split() for _ in range(x)]     # スペース区切り連続文字
    # a = [[int(c) for c in input()] for _ in range(x)]  # 数字→単数字リスト変換(行列)

    # スペース区切り連続 数字、文字列複合
    # a = []
    # for _ in range(x):
    #     aa, bb = input().split()
    #     a.append((int(aa), bb))

    # ------ 処理 ------#
    S = pow_r(10, n)

    M = pow_r(9, n)
    M2 = pow_r(8, n)

    out = (S - (M + M - M2)) % (1000000000 + 7)

    # ------ 出力 ------#
    print("{}".format(out))


Measured memory_bytes: 12776
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var s=input.trim();
var len=s.length;
var abc="0123456789AabcdefghijklmnopqrstuvwxyzA".split("");
var sum=0;
while(true){
   if(s=="")break;
   var cnt=0;
   var flag=false;
   abc.forEach(v=>{
      var re = new RegExp( v );
      if(re.test(s)){
         if(flag)cnt++;
         flag=true;
         s=s.replace(re,"");
      }else{
         if(cnt>=3)sum+=cnt-2;
         cnt=0;
         flag=false;
      }
   });
}
console.log(len-sum);


Measured memory_bytes: 16716
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    char a,b;
    cin>>a;
    switch (a)
    {
        case 'A':
            b='T';
            break;
        case 'T':
            b='A';
            break;
        case 'G':
            b='C';
            break;
        case 'C':
            b='G';
            break;
    }
    cout<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define MAX 114514
    #define NIL -1
     
    int main(){
        int n,A[MAX],ans=0;
        scanf("%d",&n);
        for(int i=0;i<n;i++) scanf("%d",&A[i]);
        A[n] = NIL;
        sort(A,A+n);
        //for(int i=0;i<n;i++) printf("%d ",A[i]);
        for(int i=0;i<n;){
            if(A[i]==A[i+1]){
                i += 2;
            }
            else{
                ans++;
                i++;
            }
        }
        printf("%d\n",ans);
    }

Measured memory_bytes: 640
n=int(input())
a=list(map(int, input().split()))
out=[0]*n
i=0
j=n-1
k=n-1
while i<=j:
  out[i]=a[k]
  k-=1
  i+=1
  if k<0:
    break
  out[j]=a[k]
  k-=1
  j-=1
print(*out)

Measured memory_bytes: 26180
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 200000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

string a[N];

int nv;
int go[1000000][26];
int cnt[1000000][26];

int tmp[26];
void add_str(string &s) {
    fill(tmp, tmp + 26, 0);
    for (char c : s) {
        tmp[c - 'a']++;
    }
    
    int cur = 0;
    for (char c : s) {
        c -= 'a';

        rep(i, 0, 26) {
            if (tmp[i] > 0) {
                cnt[cur][i]++;
            }
        }

        if (go[cur][c] == -1) {
            fill(go[nv], go[nv] + 26, -1);
            fill(cnt[nv], cnt[nv] + 26, 0);
            go[cur][c] = nv++;
        }
        cur = go[cur][c];
        tmp[c]--;
    }
}

int get(string &s) {
    int cur = 0;
    for (int i = 0; i < sz(s) - 1; i++) {
        int c = s[i] - 'a';
        if (go[cur][c] == -1) {
            return 0;
        }
        cur = go[cur][c];
    }
    int c = s[sz(s) - 1] - 'a';
    return cnt[cur][c];
}

int main()
{
    //freopen("circus.in", "r", stdin);
    //freopen("circus.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    rep(i, 0, n) {
        cin >> a[i];
        reverse(a[i].begin(), a[i].end());
    }
    ll ans = 0;
    nv = 0;
    fill(go[nv], go[nv] + 26, -1);
    fill(cnt[nv], cnt[nv] + 26, 0);
    nv++;
    rep(i, 0, n) {
        ans += get(a[i]);
        add_str(a[i]);
    }
    nv = 0;
    fill(go[nv], go[nv] + 26, -1);
    fill(cnt[nv], cnt[nv] + 26, 0);
    nv++;
    repb(i, n - 1, -1) {
        ans += get(a[i]);
        add_str(a[i]);
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 213568
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n1 = Number(lines.shift());
  const arr1 = lines.shift().split(' ').map(Number);
  const n2 = Number(lines.shift());
  const arr2 = lines.shift().split(' ').map(Number);

  const solve = memoization(function(i, m) {
    if (m == 0) return true;
    if (i >= n1) return false;
    return solve(i + 1, m) || solve(i + 1, m - arr1[i]);
  });
  arr2.map(m => solve(0, m) ? 'yes' : 'no').forEach(res => console.log(res));
})();

function memoization(f) {
  const cache = {};
  return (...param) => {
    const c = cache[param];
    return typeof c === 'undefined' ? cache[param] = f(...param) : c;
  };
}



Measured memory_bytes: 24408
#include <stdio.h>


int main(void)
{
    int N;
    int n, d;
    int x[201], y[201];
    int x_min, x_max, y_min, y_max;
    int i;

    while (1){
        scanf("%d", &N);
        if (N == 0){
            break;
        }
        
        x_min = y_min = 0;
        x_max = y_max = 0;
        x[0] = y[0] = 0;
        for (i = 1; i < N; i++){
            scanf("%d%d", &n, &d);
            
            switch (d){
              case 0:   //左
                x[i] = x[n] - 1;
                y[i] = y[n];
                if (x_min > x[i]){
                    x_min = x[i];
                }
                break;
              
              case 1:   //下
                x[i] = x[n];
                y[i] = y[n] + 1;
                if (y_max < y[i]){
                    y_max = y[i];
                }
                break;
              
              case 2:   //右
                x[i] = x[n] + 1;
                y[i] = y[n];
                if (x_max < x[i]){
                    x_max = x[i];
                }
                break;
              
              case 3:   //上
                x[i] = x[n];
                y[i] = y[n] - 1;
                if (y_min > y[i]){
                    y_min = y[i];
                }
                break;
            }
        }
        
        
        printf("%d %d\n", x_max - x_min + 1, y_max - y_min + 1);
    }
    return (0);
}



Measured memory_bytes: 2032
#   ?????????????????±??????????????????????????¢???????????????????????°?????°??????????????°??????
#   ?¨??????\??????????????????????????????

import sys
#   ???????????????????????????????????????
input_char = []
for line in sys.stdin:
    input_char.append(line)
#   ???????????????????????????
count_char = "".join(input_char)
#   print(count_char[2])
#   ????????????????????¨???????????????
countingChar = [0 for i in range(26)]
#   ??????????????¢????????????
for i in range(0, len(count_char)):
    if ord(count_char[i].lower()) - ord("a") > -1 and ord(count_char[i].lower()) - ord("a") < 27:
        countingChar[ord(count_char[i].lower()) - ord("a")] += 1
#   ??????
for i in range(0, 26):
    print("{0} : {1}".format(chr(ord("a") + i), countingChar[i]))

Measured memory_bytes: 7476
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */

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

    int ans = 1000000000;
    for(int i=0; i<s.length()-2; i++){
        int l,m,r;
        l = s[i] - '0';
        m = s[i+1] - '0';
        r = s[i+2] - '0';

        int num = 100*l + 10*m + r;
        int tmp_ans = abs(num - 753);
        if(tmp_ans < ans){
            ans = tmp_ans;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[])
{
	int x;
	cin >> x;

	for (int i = x; i > -1; --i)
	{
		double res = sqrt(i);
		int res_int = int(res);

		if(res == double(res_int)){
			cout << i << "\n";
			return 0;
		}

	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main(){
    int n, l;
    cin >> n >> l;
    vector<string> v;
    for(int i = 1; i <= n; ++i){
        string s;
        cin >> s;
        v.pb(s);
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n; ++i) cout << v[i];
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
int main()
{
       int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
       int k; cin>>k;
       cout<<arr[k-1]<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ll a,b;
  cin >> a >> b;
  vector<ll> s(1000,0);
  FOR(i,1,1000){
    s[i] += s[i-1] + i;
  }
  cout << s[b-a-1]-a << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter


class Mint:
    MOD = 1000000007  # Must be a prime
    CACHE_FACTORIALS = [1, 1]

    def __init__(self, v):
        if self.__isally(v):
            self.v = v.v % self.MOD
        else:
            self.v = v % self.MOD

    @property
    def inv(self):
        return Mint(self.__minv(self.v))

    @classmethod
    def factorial(cls, v):
        for i in range(len(cls.CACHE_FACTORIALS), int(v) + 1):
            cls.CACHE_FACTORIALS.append(cls.CACHE_FACTORIALS[-1] * i % cls.MOD)
        return Mint(cls.CACHE_FACTORIALS[int(v)])

    @classmethod
    def perm(cls, n, r):
        if n < r or r < 0:
            return 0
        return cls.factorial(n) // cls.factorial(n - r)

    @classmethod
    def comb(cls, n, r):
        if n < r or r < 0:
            return 0
        return cls.perm(n, r) // cls.factorial(r)

    @classmethod
    def __isally(cls, v) -> bool:
        return isinstance(v, cls)

    @classmethod
    def __minv(cls, v) -> int:
        return pow(v, cls.MOD - 2, cls.MOD)

    @classmethod
    def __mpow(cls, v, w) -> int:
        return pow(v, w, cls.MOD)

    def __str__(self):
        return str(self.v)
    __repr__ = __str__

    def __int__(self):
        return self.v

    def __eq__(self, w):
        return self.v == w.v if self.__isally(w) else self.v == w

    def __add__(self, w):
        return Mint(self.v + w.v) if self.__isally(w) else Mint(self.v + w)
    __radd__ = __add__

    def __sub__(self, w):
        return Mint(self.v - w.v) if self.__isally(w) else Mint(self.v - w)

    def __rsub__(self, u):
        return Mint(u.v - self.v) if self.__isally(u) else Mint(u - self.v)

    def __mul__(self, w):
        return Mint(self.v * w.v) if self.__isally(w) else Mint(self.v * w)
    __rmul__ = __mul__

    def __floordiv__(self, w):
        return Mint(self.v * self.__minv(w.v)) if self.__isally(w) else \
            Mint(self.v * self.__minv(w))

    def __rfloordiv__(self, u):
        return Mint(u.v * self.__minv(self.v)) if self.__isally(u) else \
            Mint(u * self.__minv(self.v))

    def __pow__(self, w):
        return Mint(self.__mpow(self.v, w.v)) if self.__isally(w) else \
            Mint(self.__mpow(self.v, w))

    def __rpow__(self, u):
        return Mint(self.__mpow(u.v, self.v)) if self.__isally(u) else \
            Mint(self.__mpow(u, self.v))


N = int(input())
A = [int(s) for s in input().split()]
v = Counter(A).most_common(1)[0][0]
i = A.index(v)
j = A.index(v, i+1)
l = i
m = j - i - 1
n = N - j
for k in range(1, N + 2):
    ans = Mint.comb(l + m + n, k) + Mint.comb(l + m + n, k - 1) * \
        2 - Mint.comb(l + n, k - 1) + Mint.comb(l + m + n, k - 2)
    print(ans)


Measured memory_bytes: 80104
#include<stdio.h>

int main(){
  int N,A[100],i,j,k,temp;

  //入力
  scanf("%d",&N);
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }
  
  //１行目の出力
  for(i=0; i<N; i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");

  //挿入ソート
  
  for(i=1; i<N; i++){
    temp = A[i];
    j = i-1;
    while(j>=0 && A[j]>temp){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = temp;
    //２行目以降の出力
    for(k=0; k<N; k++){
      if(k>0) printf(" ");
      printf("%d",A[k]);
    }
    printf("\n");
  }
  return 0;
}



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

int a[105];

int main(){
	int n, cnt, ans;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%d",&a[i]);
	ans = 0; cnt = 1;
	for (int i = 2; i <= n; i++){
		if (a[i] != a[i - 1]){
			ans += cnt / 2;
			cnt = 1;
		}
		else cnt++;
	}
	ans += cnt / 2;
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 256
// AIZU ONLINE JUDGE http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=10013
//*
#include <stdio.h>

int main(){
    int h, w;
    int i, j;
    while(1){
        scanf("%d %d ", &h, &w);
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if(i==0||i==h-1||j==0||j==w-1){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}
//*/


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

using namespace std;
typedef unsigned long long ull;

void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (const auto i : v) {
        os << i << " ";
    }
    os << "]";
    return os;
}


struct UnionFind {
    int size;
    vector<int> par;

    UnionFind(int N) : size(N), par(N) {
        for (int i = 0; i < N; i++) {
            par[i] = i;
        }
    }

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

    void unite(int i, int j) {
        int ri = root(i);
        int rj = root(j);
        if (ri == rj) return;
        par[ri] = rj;
    }

    bool same(int i, int j) {
        int ri = root(i);
        int rj = root(j);
        return ri == rj;
    }
};

ostream& operator<<(ostream& os, const UnionFind& u) {
    os << "UnionFind ---" << endl;
    for (int i = 0; i < u.size; i++) {
        int idx = i;
        os << idx;
        while (true) {
            int par = u.par[idx];
            if (par == idx) break;
            os << " -> " << par;
            idx = par;
        }
        os << endl;
    }
    os << "--- UnionFind";
    return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, const map<T1, T2>& m) {
    os << "{";
    for (const auto x : m) {
        os << x.first << ":" << x.second << " ";
    }
    os << "}";
    return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

int main(int argc, char const *argv[]) {
    int N, K, L;
    cin >> N >> K >> L;

    UnionFind roads(N);
    for (int i = 0; i < K; i++) {
        int p, q;
        cin >> p >> q;
        roads.unite(p-1, q-1);
    }

    UnionFind rails(N);
    for (int i = 0; i < L; i++) {
        int r, s;
        cin >> r >> s;
        rails.unite(r-1, s-1);
    }

    // cout << roads << endl;
    // cout << rails << endl;

    map<pair<int, int>, int> count;
    for (int i = 0; i < N; i++) {
        auto key = make_pair(roads.root(i), rails.root(i));
        auto iter = count.find(key);
        if (iter != count.end()) {
            iter->second += 1;
        } else {
            count[key] = 1;
        }
    }

    // cout << count << endl;

    for (int i = 0; i < N; i++) {
        auto key = make_pair(roads.root(i), rails.root(i));
        cout << count[key];
        if (i < N-1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, x;
  cin >> n >> x;
  vector<int> v(n);

  rep(i, 0, n) cin >> v[i];

  int ans = abs(v[0]- x);
  rep(i, 1, n) {
    ans = __gcd(ans, abs(v[i] - v[i-1]));
  }

  cout << ans << endl;
}


Measured memory_bytes: 3724
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	int N, T, A;
	scanf("%d%d%d",&N,&T,&A);
	int i = 0;
	int h[N];
	double t[N];
	double tn[N];
	while (i < N)
	{
		scanf("%d", &h[i]);
		tn[i] = T - h[i] * 0.006;
		t[i] = fabs((tn[i]) - A);
		i++;
	}
	int ans = 0;
	double min = t[0];
	i = 0;
	while (i < N)
	{
		// printf("%f ", t[i]);
		// printf("%f ", tn[i]);
		if (t[i] < min)
		{ 
			min = t[i];
			ans = i;
		}
		i++;
	}
	printf("%d\n", ans+1);
	return 0;
}

Measured memory_bytes: 128
n=int(input())
h=[int(i) for i in input().split()]
ans=0
ans1=[]
a=0
while 1:
    for k in range(a,n-1):
        if h[k]>=h[k+1] :
            ans+=1
            a+=1
        else:
            ans1.append(ans)
            ans=0
            a+=1
            break
    if a>=n-1:
        ans1.append(ans)
        break
print(max(ans1))


Measured memory_bytes: 63984
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD_Q 1e9 + 7;

void solve()
{

  int N;
  cin>>N;

  cout<<(N-1)/2<<endl;

  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}


Measured memory_bytes: 256
import sys
from pprint import pprint

n, m = map(int, sys.stdin.readline().strip().split(" "))

troubles = []
for _ in range(m):
    a, b = map(int, sys.stdin.readline().strip().split(" "))
    troubles.append((a, b))

breaked = -1
ans = 0
for a, b in sorted(troubles, key=lambda x: x[1]):
    # print(a, b)
    if a <= breaked < b:
        # print("pass")
        continue

    breaked = b - 1
    ans += 1

print(ans)

Measured memory_bytes: 52572
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;

int main(){
	string in, temp;
	cin >> in >> temp;
	in+=in;
	if(in.find(temp)<in.size()){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

# 初期値を入力

N = int(input())

T, A = map(int, input().split())

H = [int(x) for x in input().split()]

# メインプログラム

Dummy = 100000
Answer = 0

for i in range(N):

    Temperture = T - 0.006*H[i]
    Dis = abs(A - Temperture)

    if Dummy > Dis:
        Answer = i
        Dummy = Dis

print(int(Answer + 1) )


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

int main() {
  
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2 ;
  
  
  cout << x2-y2+y1 << " " << y2+x2-x1 << " " << x1-y2+y1 << " " << y1+x2-x1 << endl;
  

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
//ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
cin>>t;
  cout<<t*t;
}

Measured memory_bytes: 256
n=int(input())
arr=[input() for _ in range(n)]
dic={}
for i in range(n):
  if arr[i] not in dic:
    dic[arr[i]]=1
  else:
    dic[arr[i]]+=1
largest=max(dic.values())
ans=[]
for keys in dic.keys():
  if dic[keys]==largest:
    ans.append(keys)
ans=sorted(ans)
for words in ans:
  print(words)

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

int main(){
  double a, b, x;
  cin >> a >> b;
  if(((a+b)/2) > (int)((a+b)/2)){
    cout << (int)((a+b)/2) + 1 << endl;
  }else{
    cout << (int)((a+b)/2) << endl;
  }


  return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
#define ll long long int
using namespace std;

int i, j, n, a[26];
string s, ans;
vector<int>v[26];

int main()
{
    sf("%d", &n);
    for (i = 0; i < n; i++) {
        cin >> s;
        memset(a, 0, sizeof(a));
        for (j = 0; j < s.size(); j++) {
            a[s[j]-'a']++;
        }
        for (j = 0; j < 26; j++) v[j].push_back(a[j]);
    }
    for (i = 0; i < 26; i++) {
        n = *min_element(v[i].begin(), v[i].end());
        for (j = 0; j < n; j++) ans += ('a'+i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
 

int main() {
	string s,t;
	cin>>s;
	t=s;
	reverse(t.begin(),t.end());
	ll ans=0;
	for(ll i=0;i<s.size()/2;i++){
		if(s[i]!=t[i]){
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

long long int pow_int(int a, int b) {
	if (b) {
		return a*pow_int(a, b - 1);
	}
	else {
		return 1;
	}
}

pair<long long int, long long int>get(int type,string st,int aa=-1) {
	if (type == 0) {
		return make_pair(stoll(st), 1ll);
	}
	else if(type==1){
		if (st.empty())return make_pair(0, 1);
		return make_pair(stoll(st), pow_int(10, st.size()));
	}
	else {
		if (st.empty())return make_pair(0, 1);
		return make_pair(stoll(st), (pow_int(10, st.size()) - 1) * pow_int(10, aa));
	}
}
long long int gcd(long long int l, long long int r) {
	assert(l > 0 && r > 0);
	if (l > r)return gcd(r, l);
	else {
		const long long int num = r%l;
		if (num) {
			return gcd(l, num);
		}
		else {
			return l;
		}
	}
}
pair<long long int, long long int>aplus(pair<long long int, long long int>&l, pair<long long int, long long int>&r) {
	auto p=make_pair(l.first*r.second + r.first*l.second, r.second*l.second);
	if (p.first == 0) {
		return make_pair(0, 1);
	}
	auto gc(gcd(p.first, p.second));
	p.first /= gc;
	p.second /= gc;
	return p;
}
int main() {
	string st; cin >> st;
	string stl, stc, str;
	if (st.find('(') == string::npos) {
		stl = st.substr(0,st.find('.'));
		stc = st.substr(1+st.find('.'));
	}
	else {
		stl = st.substr(0, st.find('.'));
		stc = st.substr(1 + st.find('.'),st.find('(')-st.find('.')-1);
		str = st.substr(1 + st.find('('), st.find(')') - st.find('(') - 1);
	}
	auto l = get(0, stl);
	auto c = get(1, stc);
	auto r = get(2, str, stc.size());
	auto p(aplus(l, c));
	auto q(aplus(p, r));

	cout << q.first << "/" << q.second << endl;

	return 0;
}

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

int N;
long long A[100000],B[100000],C[100000];
long long ans=0,A_dis,C_dis;

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  for(int i = 0; i < N; i++){
    cin >> B[i];
  }
  for(int i = 0; i < N; i++){
    cin >> C[i];
  }

  sort(A,A+N);
  sort(B,B+N);
  sort(C,C+N);

  for(int j = 0; j < N; j++){
    A_dis = distance(A,lower_bound(A,A+N,B[j]));
    C_dis = N - distance(C,upper_bound(C,C+N,B[j]));

    //cout << distance(C,upper_bound(C,C+N,B[j])) << endl;
    ans += A_dis * C_dis;
  }

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

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

#define llint long long int

using namespace std;

int main(){
    int N;

    cin >> N;

    vector<int> count(4, 0);

    for(int i = 0; i < N; i ++){
        string S;

        cin >> S;

        if(S == "AC"){
            count[0] ++;
        }else if(S == "WA"){
            count[1] ++;
        }else if(S == "TLE"){
            count[2] ++;
        }else{
            count[3] ++;
        }
    }
    cout << "AC x " << count[0] << endl;
    cout << "WA x " << count[1] << endl;
    cout << "TLE x " << count[2] << endl;
    cout << "RE x " << count[3] << endl;
}

Measured memory_bytes: 3628
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @x,@y = gets.split.map(&:to_i)    
  end

  def solve
    ans = query(x) + query(y) + bonus(x,y)
  end

  def query(x)
    return 0 if 3 < x
    (4 - x) * 100_000
  end

  def bonus(x,y)
    x == 1 && y == 1 ? 400_000 : 0
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end

Measured memory_bytes: 14412
using System;
class Program {
    static void Main(string[] args){
        string input1 = Console.ReadLine();
        int num = int.Parse(input1);
        string[] cities = new string[num];
        int[] scores = new int[num];
        int[] ids = new int[num];
        for(int i = 0; i < num; i++){
            string[] input2 = Console.ReadLine().Split(' ');
            cities[i] = input2[0];
            scores[i] = int.Parse(input2[1]);
            ids[i] = i + 1;
        }

        bool isEnd = false;
        while(!isEnd){
            isEnd = true;
            for(int i = 0; i < num - 1; i++){
                if(String.Compare(cities[i], cities[i + 1]) > 0){
                    string tmpCity = cities[i];
                    cities[i] = cities[i + 1];
                    cities[i + 1] = tmpCity;
                    int tmpScore = scores[i];
                    scores[i] = scores[i + 1];
                    scores[i + 1] = tmpScore;
                    int tmpId = ids[i];
                    ids[i] = ids[i + 1];
                    ids[i + 1] = tmpId;
                    isEnd = false;
                }
                else if(cities[i] == cities[i + 1]){
                    if(scores[i] < scores[i + 1]){
                        string tmpCity = cities[i];
                        cities[i] = cities[i + 1];
                        cities[i + 1] = tmpCity;
                        int tmpScore = scores[i];
                        scores[i] = scores[i + 1];
                        scores[i + 1] = tmpScore;
                        int tmpId = ids[i];
                        ids[i] = ids[i + 1];
                        ids[i + 1] = tmpId;
                        isEnd = false;
                    }
                }
            }
            if(isEnd) break;
        }

        foreach (int id in ids){
            Console.WriteLine(id);
        }
    }
}

Measured memory_bytes: 13404
#include <bits/stdc++.h>
#define F first
//#define S second
//#define T second.first
//#define C second.second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pair<int,int>> piii;

const int N= 1e5+5, L = 14, OO = 0x3f3f3f3f;
const ll M=10 ;
const double ESP = 1e-8;


int main(){
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    map<string ,ll>mp;
    set<string>st;
    for(int i=0;i<n;i++){
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
        st.insert(s);
    }
    ll ans = 0;
    for(string z: st){
        ll x = mp[z];
        if(x){

            ans+= x*(x-1LL)/2LL;
        }
    }
    cout<<ans<<endl;
}
/*
*/


Measured memory_bytes: 20608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
#define INF 2139062143

void heap(int);

int arr[500001];
int n;

int main(int argc,char* argv[]){
  memset(arr,127,sizeof(arr));

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

  //calc
  for(int i=n/2;i>0;i--)
    heap(i);

  //output
  for(int i=1;i<=n;i++)
    cout<<" "<<arr[i];
  cout<<endl;

  return 0;
}

void heap(int nd){
  int lft=nd*2, rht=nd*2+1,largest=nd;

  if(lft<=n && arr[largest]<arr[lft])
    largest=lft;
  if(rht<=n && arr[largest]<arr[rht])
    largest=rht;

  if(largest!=nd){
    swap(arr[nd],arr[largest]);
    heap(largest);
  }
}

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

using namespace std;

#define FC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define FIN freopen("in.txt","r",stdin)
#define FOUT freopen("out.txt","w",stdout)
#define deb(x) cerr<<"DEBUG------"<<'\n';cerr<<#x<<"------>";err(x)

template<typename T>
void err(T a){
    cerr<<a<<'\n';
    cerr<<"END OF DEBUG"<<'\n'<<'\n';
}

const long double PI=acos(-1.0);  
const long double eps=1e-6;
const long long maxw=(long long)1e17+(long long)10;

using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

/*head------[@cordercorder]*/

const int maxn=(int)1e5+10;

int n;
int a[maxn],b[maxn],c[maxn];
int dp[maxn][3];

void solve(){
    for(int i=1;i<=n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    int ans=max(dp[n][0],dp[n][1]);
    ans=max(dp[n][2],ans);
    printf("%d\n",ans);
}

int main(void){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d %d %d",&a[i],&b[i],&c[i]);
    }
    solve();
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int t = sc.nextInt();
    
    int date[] = new int[n*2];
    int cost = 1001;
    
    for(int i = 0 ; i < n*2 ; ++i){
      date[i] = sc.nextInt();
    }
    
    for(int i = 1;i<n*2;i+=2){
      if(date[i] <= t && date[i-1]<cost){
        cost = date[i-1];
      }
    }
    
    if(cost == 1001){
      System.out.println("TLE");
    }else{
      System.out.println(cost);
    }  
  }
}

Measured memory_bytes: 36036
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
	string s;
	cin >> s;
	for(int i = 0; i < s.size() - 1; i++){
		for(int j = i + 1; j <= i + 2 && j < s.size(); j++){
			if(s[i] == s[j]){
				printf("%d %d\n", i + 1, j + 1);
				return 0;
			}
		}
	}
	printf("-1 -1\n");
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=1;
	for(int i=1;i<s.size();i++){
		if(s[i]!=s[i-1]){
			ans++;
		}
		
		
		
	}
	cout<<ans;
	
	
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n,k,x,y;
	cin >> n >> k >> x >> y;
	if(n <= k) cout << x * n << endl;
	else cout << x * k + (n - k) * y << endl;
}

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

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 (a>b) { a=b; return 1; } return 0; }
#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<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    int n,k;
    cin>>n>>k;
    --k;
    string s;
    cin>>s;
    rep(i,n){
        if(i!=k){
            cout<<s[i];
        }
        else{
            char tmp;
            tmp=(char)s[i]+32;
            cout<<tmp;
        }
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n - k; i++) {
        if (a[i] < a[i+k]) cout << "Yes" << '\n';
        else cout << "No" << '\n';
    }
}

Measured memory_bytes: 4840
#include <stdio.h>

struct Data
{
	int count;
	int GCD;
};

void GCD_data(int a, int b, struct Data *data)
{
	if (a < b){
		int tmp = a;
		a = b;
		b = tmp;
	}
	if (b == 0){
		data->GCD = a;
	}
	else {
		data->count++;
		GCD_data(b, a % b, data);
	}
}

int main(void)
{
	int a, b;
	
	while (scanf("%d %d", &a, &b) * a != 0){
		struct Data data;
		
		data.count = 0;
		GCD_data(a, b, &data);
		printf("%d %d\n", data.GCD, data.count);
	}
	
	return 0;
}

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

import numpy as np

vals = []
for i in range(N):
    v = list(map(int, input().split(" ")))
    vals.append(v)

vals = np.array(vals)

import itertools

prod = []
for i in range(1, N+1):
    v = list(itertools.combinations(range(N), i))
    prod.extend(v)
    
money = 1e10

for p in prod:
    ans = np.zeros(M+1)
    
    for p_ in p:
        ans += vals[p_]
    
    flag = True
    for j in range(M):
        if ans[1+j] < X:
            flag = False
    if flag:
        if money > ans[0]:
            money = ans[0]
 
if money >= 1e10:
    print(-1)
else:
    print(int(money))

Measured memory_bytes: 27368
#include<stdio.h>
#include<stdlib.h>
int c=0;

int* Bubble(int N, int *A){
  int flag=1, j, num;
  while(flag){
    flag=0;
    for(j=N-1 ; j>0 ; j--){
      if(A[j]<A[j-1]){
        num=A[j];
        A[j]=A[j-1];
        A[j-1]=num;
        flag=1;
        c++;
      }
    }
  }
  return A;
}

int main(void){
  int N,i;
  int *A;
  while(1){
  scanf("%d",&N);
  if(N>=1 && N<=100)break;
}
  A = (int*)malloc(sizeof(int)*N);
  for(i=0 ; i<N ; i++){
    while(1){
    scanf("%d",&A[i]);
    if(0<=A[i] && A[i]<=100)break;
  }
  }
  A=Bubble(N,A);
  printf("%d",A[0]);
  for(i=1 ; i<N ; i++){
    printf(" %d",A[i]);
  }
  printf("\n%d\n",c);
  return 0;
}


Measured memory_bytes: 2084
#include <iostream>
#include <string>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

#define FOR(var,start,end) for(int var=start; var<end; var++)
#define REP(var,cnt) FOR(var,0,cnt)

int main(void) {

	int N;
	cin >> N;
	
	bool mise[110][10];
	
	REP(i, N) {
		REP(zikan, 10) {
			int inp;
			cin >> inp;
			mise[i][zikan] = (inp==1);
		}
	}
	
	long rieki[110][11];
	REP(i, N) {
		REP(kabu, 11) {
			cin >> rieki[i][kabu];
		}
	}
	
	
	long ret = LONG_MIN;
	for(int zzz=1; zzz<1024; zzz++) {
		
		long prof = 0;
		REP(i, N) {
			int kosuu = 0;
			REP(zikan, 10) {
				if ( (zzz & (1<<zikan)) && mise[i][zikan] ) {
					kosuu++;
				}
			}
			
			prof += rieki[i][kosuu];
		}
		
		if ( ret < prof ) { 
			ret = prof;
		}
	}
	
	cout << ret << endl;
	
}


Measured memory_bytes: 256
D = int(input())
c = map(int,input().split())
s = [input().split() for l in range(D)]
"""
t = []
for i in range(D):
    t += [int(input())]
manzoku = 0
d = 1
"""

for i in range(1,D+1):
    print((i%26)+1)
"""
while True:
    #タイプはt[d] 満足度増加 s[d-1][t[d]-1]
    manzoku += s[d-1][t[d]-1]
"""





    

Measured memory_bytes: 9652
#include<iostream>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
#define ll long long

ll N, T;
ll t[200000];

ll s, e;
ll tsum;

int main(){
    cin >> N >> T;
    REP(i, N){
        cin >> t[i];
    }

    s = t[0];
    e = t[0]+T;
    tsum = 0;
    REP(i, N){
        if(e>=t[i]) {
            e = t[i] + T;
        } else {
            tsum += e-s;
            s = t[i];
            e = t[i] + T;
        }
    }
    tsum += e-s;

    cout << tsum << endl;
}


Measured memory_bytes: 1792