akhauriyash/Code-Regression huggingface dataset:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N, M = s_inpl()

diff = M-N*2
# Sが使え切れる場合
if diff>=0:
    M = M-N*2
    ans = N
    ans += M//4
    print(ans)
else:
    print(M//2)

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

int main(){
  unsigned long x , y , z ;
  
  cin >> x;
  
  y = x/11;
  y *= 2;
  z = x%11;

  
  
  if (z > 6)
    y += 2;
  else if ( z == 0 )
    y = y;
  else 
    y++;

  cout << y << endl;

  return 0;
}

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

int n, ans, mindiff;
bool color[] = {false, false, false, false, false, false, false, false};

int main()
{
    cin >> n;

    for (int i = 0, a; i < n; i++)
    {
        cin >> a;
        if (a <= 399)
        {
            color[0] = true;
        }
        else if (a >= 400 && a <= 799)
        {
            color[1] = true;
        }
        else if (a >= 800 && a <= 1199)
        {
            color[2] = true;
        }
        else if (a >= 1200 && a <= 1599)
        {
            color[3] = true;
        }
        else if (a >= 1600 && a <= 1999)
        {
            color[4] = true;
        }
        else if (a >= 2000 && a <= 2399)
        {
            color[5] = true;
        }
        else if (a >= 2400 && a <= 2799)
        {
            color[6] = true;
        }
        else if (a >= 2800 && a <= 3199)
        {
            color[7] = true;
        }
        else
        {
            ans++;
        }
    }

    for (bool i : color)
    {
        if (i)
        {
            mindiff++;
        }
    }

    ans += mindiff;
    if (mindiff == 0)
    {
        mindiff++;
    }
    cout << mindiff << ' ' << ans << endl;
}


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

typedef long long ll;

int N;
int A[100010];

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

    for(int i = 0; i <= N; i++)
    {
        if(N == i)
        {
            cout << "Yes" << endl;
            return 0;
        }
        if(A[i] != 0)break;
    }

    sort(A, A + N);

    if(N % 3 != 0)
    {
        cout << "No" << endl;
        return 0;
    }

    for(int i = 0; i <= N; i++)
    {
        if(i == N)
        {
            cout << "Yes" << endl;
            return 0;
        }
        if(i < N / 3)if(A[i] != 0)break;
        if(i >= N / 3 && i != N - 1)if(A[i] != A[i + 1])break;
    }

    for(int i = 0; i <= N; i++)
    {
        if(i == N && (A[0] ^ A[N / 3]) == A[N - 1])
        {
            cout << "Yes" << endl;
            return 0;
        }
        if(i != 0 && i < N / 3)
        {
            if(A[i] != A[i - 1])break;
        }
        if(i != N / 3 && N / 3 <= i && i < N / 3 * 2)
        {
            if(A[i] != A[i - 1])break;
        }
        if(i != N / 3 * 2 && N / 3 * 2 <= i && i < N)
        {
            if(A[i] != A[i - 1])break;
        }
    }

    cout << "No" << endl;

    return 0;
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

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

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

        int N;
        std::cin >> N;

        vector<int> H(N);
        REP(i, N) {
            std::cin >> H[i];
        }

        int ans = 0;
        REP(i, N) {
            bool ok = true;
            for(int j = 0; j < i; j++) {
                if(H[i] < H[j]) {
                    ok = false;
                    break;
                }
            }
            ans = (ok) ? ans + 1 : ans;
        }

        std::cout << ans << std::endl;
    }
    catch(const exception& e) {
        std::cout << e.what() << std::endl;
        exit(1);
    }
    return 0;
}


Measured memory_bytes: 892
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

h1,m1,h2,m2, k = MAP()

if(m2>=m1):

    time = (h2-h1)*60 + (m2-m1)
else:
    time = 60-m1
    h1+=1
    m1 = 0
    time += (h2-h1)*60 + abs(m2-m1)
print(time-k)

Measured memory_bytes: 68236
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef pair<ul, ul> P;




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

    if(N%2==0){
		cout << N << endl;
	}else{
		cout << 2 * N << endl;
	}

	return 0;
}

Measured memory_bytes: 256
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int n,ret,two,ai;
unordered_map<int, int> a;

int main(){
    I(n);
    REP(i,n){
        I(ai);
        a[ai]++;
        if (a[ai] == 3) a[ai] = 1;
    }
    for (auto i : a){
        ret++;
        if (i.second==2) two++;
    }
    if (two%2) ret--;
    cout << ret << endl;
}


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

using namespace std;
int calch(int x, int y, const vector<vector<char> > &s) {
	int res = 0;
	int b = x, f = x;
	if(s[x][y] == '#') return -1;
	while(b >= 0 && s[b][y] == '.') b--, res++;
	while(f < s.size() && s[f][y] == '.') f++, res++;
	res--;
	return res;
}
int calcw(int x, int y, const vector<vector<char> > &s) {
	int res = 0;
	int b = y, f = y;
	if(s[x][y] == '#') return -1;
	while(b >= 0 && s[x][b] == '.') b--, res++;
	while(f < s[x].size() && s[x][f] == '.') f++, res++;
	res--;
	return res;
}
int main() {
	int H, W;
	cin >> H >> W;

	vector<vector<char> > s(H, vector<char>(W));

	for(auto &r: s)
		for(auto &x: r) cin >> x;

	int bh[W];
	for(int i = 0; i < W; i++) bh[i] = -1;
	int bw = -1;
	int res = 0;
	for(int i = 0; i < H; i++) {
		bw = -1;
		for(int j = 0; j < W; j++) {
			if(s[i][j] == '#') {
				bw = -1;
				bh[j] = -1;
				continue;
			}
			if(bw == -1) bw = calcw(i, j, s);
			if(bh[j] == -1) bh[j] = calch(i, j, s);
			//cout << "(" << i << "," << j << ")=" << bw + bh[j] -1 << endl;
			res = max(res, bw + bh[j] - 1);
		}
	}

	cout << res << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MT make_tuple
#define PB push_back
typedef long long ll;

int N, K, root, ans=2e9;
vector<int> adj[2200];

int get (int i, int p, int d, int mx) {
        if (d > mx) return 0;
        int ret = 1;
        for (int j : adj[i]) if (j != p) ret += get(j, i, d+1, mx);
        return ret;
}

int main () {
        scanf("%d %d", &N, &K);
        fo(i, 0, N-1) {
                int a, b; scanf("%d %d", &a, &b);
                adj[a].PB(b), adj[b].PB(a);
        }
        fo(i, 1, N+1) {
                int t = 0;
                for (int j : adj[i]) t += get(j, i, 1, K/2);
                for (int j : adj[i]) {
                        int o = t;
                        t -= get(j, i, 1, K/2);
                        t += get(j, i, 1, (K+1)/2);
                        ans = min(ans, N - t - 1);
                        t = o;
                }
        }
        printf("%d\n", ans);
        return 0;
}


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


    class Program
    {
        static void Main(string[] args)
        {
            string[] Input = Console.ReadLine().Split(' ');
            long N = long.Parse(Input[0]);
            long M = long.Parse(Input[1]);
            string[] Input2 = Console.ReadLine().Split(' ');
            for(long i = 0; i < M; i++){
                long A = long.Parse(Input2[i]);
                N -= A;
                if(N < 0){
                    N = -1;
                    break;
                }
            }
            Console.WriteLine(N);
        }
    }


Measured memory_bytes: 28292
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		double p = Math.PI;
		double r = sc.nextDouble();
		System.out.println(String.format("%.7f",r*r*p)+" "+String.format("%.7f",2*r*p));
		
	}
}


Measured memory_bytes: 28336
// B - Ruined Square
// https://atcoder.jp/contests/abc108/tasks/abc108_b
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, d, h, k, n, x1, x2, y1, y2, w, ans = 0, count = 0;
  string s, t;
  cin >> a >> b >> c >> d;
  w = c - a;
  h = d - b;
  // if (c - a > 0)
  // {
  x1 = a + (w - h);
  y1 = b + (w + h);
  x2 = c - (w + h);
  y2 = d + (w - h);
  // }
  // else
  // {
  //   x1 = a - (w + h);
  //   y1 = b - (w - h);
  //   x2 = c + (w - h);
  //   y2 = d - (w + h);
  // }
  cout << x1 << " " << y1 << " " << x2 << " " << y2 << "\n";
}

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

const int INF = 2e9;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    vector<int> cnt(n,0);
    cnt[0]++;
    int r;
    int now = 0;
    int fir = 0;
    int sec = 0;
    while(true){
        r = now;
        now = a[now];
        cnt[now]++;
        if(cnt[now] == 1) fir++;
        if(cnt[now] == 2) sec++;
        if(cnt[now] == 3) break;
    }
    if(k <= fir){
        int s = 0;
        rep(i,k){
            s = a[s];
        }
        cout << s+1 << endl;
    }
    else{
        k -= fir;
        k %= sec;
        rep(i,k){
            r = a[r];
        }
        cout << r+1 << endl;
    }
}

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

using namespace std;

int m,n,c[10][10];

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	cin >> m >> n;
	for(int i = 0; i < 10; i++)
		for(int j = 0; j < 10; j++) cin >> c[i][j];

	for(int k = 0; k < 10; k++)
		for(int i = 0; i < 10; i++)
			for(int j = 0; j < 10; j++)
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);

	long long res = 0;
	for(int i = 1; i <= m; i++)
		for(int j = 1; j <= n; j++) {
			int x; cin >> x;
			if (x != -1) res += c[x][1];
		}

	cout << res;
}


Measured memory_bytes: 256
n,k = (int(x) for x in input().split())
A = [int(x) for x in input().split()]

flag = [False] * n

town = 1
towns = [1]
flag[0] = True

while(True):
    ntown = A[town-1]
    if flag[ntown-1]:
        l_s = towns.index(ntown)
        
        if k < l_s:
            print(towns[k])
            break
        else:
            l = towns[l_s:]
            k -= l_s
            print(l[k%len(l)])
            break
        
    else:
        flag[ntown-1] = True
        towns.append(ntown)
        town = ntown
        
#print(l, l_s)





Measured memory_bytes: 32272
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(void)
{
  char w[11];
  char t[1001];
  int count=0;
  scanf("%s",w);
  for(int i=0;i<strlen(w);i++){
    w[i]=tolower(w[i]);
  }
  while(1){
    scanf("%s",t);
    if(strcmp(t,"END_OF_TEXT")==0){
      break;
    }
    for(int j=0;j<strlen(t);j++){
      t[j]=tolower(t[j]);
    }
    if(strcmp(w,t)==0){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}
  


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

int main(){
  int n, k, c;
  int a[200010] = {};
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> c;
    a[c]++;
  }
  sort(a, a+n, greater<int>());
  int sum = 0, count = 0;
  for(int i = 0; i < k; i++) sum += a[i];
  cout << n - sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
// }}}


signed main()
{
    int N;
    int cnt[1000010] {};

    cin >> N;
    rep(i, 0, N) {
        int a; cin >> a;
        cnt[a] += 1;
    }

    int ans = 0;
    for (int i = 1; i <= int(1e5); ++i) {
        chmax(ans, cnt[i] + cnt[i-1] + cnt[i+1]);
    }

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


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef long long LL;
//-------------------------------------------------------------------LYYY↓
namespace LYYY{
	int read()
	{
		int s=0;char c=getchar();int f=1;
		while(c<48||c>57)
		{
			if(c==45) f=-1;
			c=getchar();
		}
		while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
		return s*f;
	}
	void write(int x)
	{
		if(x>=10) write(x/10);
		putchar(x%10+48);
	}
	void W(int x)
	{
		if(x<0) x=-x,putchar(45);
		write(x);
	}
}using namespace LYYY;
//-------------------------------------------------------------------bianliang↓
int ju[1111][1111];
//-------------------------------------------------------------------hanshu↓
//-------------------------------------------------------------------main()↓
int main()
{
	int N=read(),M=read(),A=read(),B=read();
	for(int i=1;i<=B;++i)for(int j=1;j<=A;++j) ju[i][j]=1;
	for(int i=B+1;i<=N;++i)for(int j=A+1;j<=M;++j) ju[i][j]=1;
	for(int i=1;i<=N;++i)
	{
		for(int j=1;j<=M;++j) write(ju[i][j]);puts("");
	}
	return 0;
}

Measured memory_bytes: 5504
N = int(input())
L = [0] * N
M = [0] * N
for i in range(N):
    L[i], M[i] = map(str, input().split())
K = [int(s) for s in M]
X = str(input())
t = L.index(X)
count = 0
for i in range(t + 1, N):
    count += K[i]
print(count)

Measured memory_bytes: 3064
extern crate core;

use std::char;
use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
  ($line:expr, $name:ident, $t:tt) => {
    let $name = value!($line, $t);
  };
}

macro_rules! values_def {
  ($lines:expr, $n:expr, $name:ident, $t:tt) => {
    let $name = {
      let mut vec = Vec::new();
      for i in 0..$n {
        let mut next = $lines.next().unwrap().split_whitespace();
        vec.push(value!(next, $t));
      }
      vec
    };
  };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
  let mut input = String::new();
  io::stdin().read_to_string(&mut input).unwrap();
  let output = solve(input.trim().to_string());
  println!("{}", output);
}

fn solve(input: String) -> String {
  input!(input=>(n:usize k:usize)(s:#));
  let s = s.chars().collect::<Vec<char>>();
  let mut res = String::new();

  for i in 0..n {
    if k - 1 == i {
    res.push(match s[i]{
      'A'=>'a',
      'B'=>'b',
      'C'=>'c',
      _=>unimplemented!()
    });
    } else {
      res.push(s[i]);
    }
  }
  res.chars().collect::<String>()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 1\nABC\n" => "aBC\n",
    test2: "4 3\nCABA\n" => "CAbA\n",
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	cin>>s;
	ll n=s.size()/2;
	rep(i,n){
		bool h=true;
		rep(j,n-i-1)if(s[j]!=s[j+n-i-1])h=false;
		if(h){
			cout<<(n-i-1)*2<<endl;
			return 0;
		}
	}
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	double h,m;
	rep(i,0,n){
		scanf("%lf:%lf",&h,&m);
		if(h>=12) h-=12;
		h=30*h+0.5*m;
		m=6*m;
		double ans=abs(h-m);
		//o(ans);
		if(ans>180) ans=360-ans;
		if(ans<30) o("alert");
		else if(ans>=90) o("safe");
		else o("warning");
	}
}

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

int main()
{
  int M,D,a,b;
  cin >>M;
  cin >>D;
  int A[110]={0};
  if(D<20||M<4) cout<<0<<endl;
  else if(D>=20&&M>=4){
    for(int i=20;i<=D;i++){
      a=i/10;
      b=i%10;
      A[a*b]+=1;
    }
    int ans=0;
    for(int i=4;i<=M;i++) ans+=A[i];
    if((D-1)/10>=4){
      ans-=(D-1)/10;
      ans+=3;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int w,i,n,s[30],a[30],b[30],temp;

  scanf("%d",&w);
  scanf("%d",&n);

  for(i=0;i<w;i++)
    s[i]=i+1;

  for(i=0;i<n;i++){
    scanf("%d,%d",&a[i],&b[i]);
    a[i]--;b[i]--;
  }

  for(i=0;i<n;i++){   
    temp=s[a[i]];
    s[a[i]]=s[b[i]];
    s[b[i]]=temp;
  }

  for(i=0;i<w;i++)
    printf("%d\n",s[i]);
  
  

  return(0);
}

Measured memory_bytes: 596
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <climits>

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

#define int long long

using namespace std;

signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int x;
    
    cin >> x;
    
    int ans = (x / 11) * 2;
    x %= 11;
    if (x != 0) {
        if (x <= 6) ans++;
        else ans += 2;
    }
    
    cout << ans << endl;
}


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

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  for(int i=0; i<num; i++){ cout << v[i].first << v[i].second; if(i!=num-1) cout << " ";}
  cout << endl;
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

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

  map<string, int> mp;
  for(int i=0; i<n; i++){
    string command, s;
    cin >> command >> s;
    if(command == "insert"){
      mp[s]++;
    }
    else if(command == "find"){
      if(mp[s] > 0) cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }

}




Measured memory_bytes: 52388
#include <stdio.h>  /* printf, scanf */
#include <stdbool.h> /* bool */

static void Read(int* x);
static void Calc(int x, int* response);
static void Write(int target);
static bool RangeCheck(int x);

int main()
{
    int x = 0, ans = 0;

    Read(&x);

    if (!RangeCheck(x)) {
        return -1;
    }

    Calc(x, &ans);

    Write(ans);

    return 0;
}

void Read(int* x)
{
    scanf("%d", x);
}

void Calc(int x, int* response)
{
    *response = x * x* x;
}

void Write(int target)
{
    printf("%d\n", target);
}

bool RangeCheck(int x)
{
    return (x >= 1) && (x <= 100) ? true : false;
}



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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {
    vector<string> kup(3);
    for(auto &i: kup) {
        cin >> i;
        reverse(i.begin(), i.end());
    }
        

    int turn = 0;
    while(!kup[turn].empty()) {
        int t = kup[turn].back() - 'a';
        kup[turn].pop_back();
        turn = t;
    }

    if(turn == 0) {
        printf("A\n");
    } else if(turn == 1) {
        printf("B\n");
    } else {
        printf("C\n");
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <string.h>

using namespace std;

struct p {
	bool s;
	int count;
};

int n;

int main() {

	while (scanf("%d", &n), n != 0) {
		p rc[100000];
		bool C;
		int  c, t = -1, I = 0;

		memset(rc, 0, sizeof(rc));

		for (int i = 1; i <= n; i++) {
			scanf("%d", &c);
			if (c == 1) C = true;
			else C = false;

			if (c != t) {
				if (i % 2 == 0) {
					rc[I].s = C;
					rc[I].count++;
					if (rc[I].s == rc[I - 1].s && I != 1) {
						rc[I - 1].count += rc[I].count;
						rc[I].count = 0;
						I--;
					}
				}
				else {
					I++;
					rc[I].s = C;
					rc[I].count = 1;
				}
			}
			else rc[I].count++;
			t = c;
		}
		int ans = 0;
		for (int i = 1; i <= I; i++) {
			if (!rc[i].s) {
				ans += rc[i].count;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3408
#include <bits/stdc++.h>
using namespace std;
int nr(int n)
{
    int s=0;
    while(n)
    {
        s=s*10+n%10;
        n/=10;
    }
    return s;
}
int main()
{
	int i,n,m,s=0;
	scanf("%d%d",&n,&m);
	for(i=n;i<=m;i++)
	{
		if(nr(i)==i)
			s++;
	}
	printf("%d",s);
	return 0;
}

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

int main(){
	int data[3];
	while(std::cin>>data[0]>>data[1]>>data[2],data[0],data[1],data[2]){
		int n;
		double min;
		std::sort(data,data+3);
		std::cin>>n;
		min=sqrt(data[0]*data[0]+data[1]*data[1])/2;
		for(int i=0,r;i<n;i++){
			std::cin>>r;
			if(r>min)std::cout<<"OK"<<std::endl;
			else std::cout<<"NA"<<std::endl;
		}
	}
	return 0;
}

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

using namespace std;

long long c[30010], w[30010];
long long f[110][100100];

int main()
{
    int N, V, i, j;

    cin>>N>>V;

    for(i=1;i<=N;i++)
        cin>>c[i]>>w[i];
    for(i=1;i<=N;i++)
    {
        for(j=1;j<=V;j++)
            if(j >= c[i])
                f[i][j] = max(f[i-1][j-c[i]] + w[i], f[i-1][j]);
            else
                f[i][j] = f[i-1][j];
    }

    cout<<f[N][V]<<endl;

    return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
ll p[20],c[20];
int main(){
  ll D,G;cin>>D>>G;
  rep(i,D)cin>>p[i]>>c[i];
  ll Min=INT_MAX;
  rep(i,1<<D){
    ll cnt=0;
    ll sum=0;
    rep(j,D){
      if(i>>j&1){
        cnt+=p[j];
        sum+=p[j]*100*(j+1)+c[j];
      }
    }
    for(int j=D-1;j>=0;j--){
      if(i>>j&1)continue;
      int a=p[j];
      while(sum<G&&a){
        a--;
      sum+=100*(j+1);
      cnt++;
    }
  }
  if(sum>=G)Min=min(Min,cnt);
}
cout<<Min<<endl;
}
  

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[201010],b[202002],n,l;
long long ans,sum[222222],sum2[222222],s1[222222],s2[222222];
long long gett(int x,int y)
{
//	printf("%lld|%lld\n",sum[y],sum[x]);
	return sum[y]-sum[x]-s1[x]*(y-x);
}
long long gett2(int pl)
{
	return sum2[pl];
}
long long calc(int x)
{
	int tmp,pl=x+(n-x+2)/2;
	long long ans=0;
	if((n-x)%2==1)
		tmp=1;
	else tmp=0;
//	printf("%d %d\n",pl,tmp);
	if(tmp==1)
		ans-=s2[pl];
	else ans-=s1[pl-1]-s1[x];
//	printf("%lld %lld\n",ans,gett(x,pl-1));
	ans+=gett2(pl)*2+2*gett(x,pl-1)+(long long)a[x]*(n-x+1);
	return ans;
}
void solve(int n)
{
	int i;
	for(i=1;i<=n;i++)
		s1[i]=s1[i-1]+a[i]-a[i-1],sum[i]=sum[i-1]+s1[i];
	for(i=n;i;i--)
	{
		s2[i]=s2[i+1]+a[i+1]-a[i];
		sum2[i]=sum2[i+1]+s2[i];
//		printf("%d %d\n",i,sum2[i]); 
	}
	for(i=1;i<=n;i++)
//		printf("%d %d||\n",i,calc(i));
		ans=max(ans,calc(i));
}
int main()
{
	
//	freopen("a.in","r",stdin);
//	freopen("lyf.out","w",stdout);
	int i;
	scanf("%d%d",&l,&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	ans=max(l-a[1],a[n]);
	a[n+1]=l;
	solve(n);
	for(i=1;i<=n;i++)
		b[i]=l-a[n-i+1];
	for(i=1;i<=n;i++)
		a[i]=b[i];
	solve(n);
	printf("%lld\n",ans);
 	return 0;
}


Measured memory_bytes: 8576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[]){
	int N, M;
	scanf("%d %d", &N, &M);

	int A = M + 2;
	int B = M + 1;
	int C = 2*M + 2;
	for(int i=1, j=0; j < M; i++){
		printf("%d %d\n", i, A - i);
		if(++j < M){
			printf("%d %d\n", B + i, C - i);
			j++;
		}
	}
	return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, W, X, Y, Z;
string S, T;

signed main(){
	std::cin >> A>>B;
	std::cout << A*B << std::endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int n;cin >> n;
    vi x(n),y(n);
    rep(i,n) cin >> x[i] >> y[i];
    map<P,int> mp;
    rep(i,n){
        rep(j,n){
            int p=x[j]-x[i];
            int q=y[j]-y[i];
            if(p==0&&q==0) continue;
            mp[{p,q}]=1;
        }
    }
    rep(i,n){
        rep(j,n){
            int subx=x[j]-x[i];
            int suby=y[j]-y[i];
            if(subx==0&&suby==0) continue;
            if(mp[{subx,suby}]>0) mp[{subx,suby}]++;
        }
    }
    int ans=INF;
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    for(auto p: mp){
        int cost=n-(p.second-1);
        chmin(ans,cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	char c;
  	cin>>c;
  	string s="abcdefghijklmnopqrstuvwxyz";
  	for(int i=0;i<26;i++){
     	if(s[i]==c){
        	cout<<s[i+1]<<endl;
        } 
    }
}

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

class FenwickTree {
private:
    int n;
    vector<ll> dat;
public:
    FenwickTree(int _n): n(_n), dat(_n+1, 0) {}
    FenwickTree(int _n, ll init): n(_n), dat(_n+1, 0) {
        for (int i = 0; i < _n; i++) {
            add(i, init);
        }
    }
    
    void add(int idx, ll value) {
        for (idx++; idx <= n; idx += idx & -idx) {
            dat[idx] += value;
        }
    }

    ll query(int l, int r) {
        ll ans = 0;
        for (r++; r > 0; r -= r & -r) {
            ans += dat[r];
        }
        for (; l > 0; l -= l & -l) {
            ans -= dat[l];
        }
        return ans;
    }
};

bool comp(pair<int,int> a, pair<int,int> b)
{
    return a.second - a.first < b.second - b.first;
}

int main(void)
{
    int n, m;
//    cin >> n >> m;
    scanf("%d%d", &n, &m);

    vector< pair<int,int> > A(n);
    for (int i = 0; i < n; i++) {
//        cin >> A[i].first >> A[i].second;
        scanf("%d%d", &A[i].first, &A[i].second);
    }
    sort(A.begin(), A.end(), comp);

    FenwickTree ft(m+1);

    int idx = 0;
    for (int d = 1; d < m+1; d++) {
        for(; idx < n && A[idx].second - A[idx].first < d; idx++) {
            ft.add(A[idx].first, 1);
            ft.add(A[idx].second+1, -1);
        }
        ll count = n - idx;
        for (int i = 0; i < m+1; i += d) {
            count += ft.query(0, i);
        }
//        cout << count << endl;
        printf("%d\n", count);
    }
}


Measured memory_bytes: 4096
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

typedef long long ll;
ll k;
string s;

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

	if (s.size() <= k) {
		cout << s << endl;
	}
	else {
		for (ll i = 0; i < k; i++) {
			cout << s[i];
		}
		cout << "..." << endl;
	}

	return 0;
}

Measured memory_bytes: 3676
use std::cmp::min;

fn main() {
	let dg: Vec<i32> = read_vec();
	let (d, g)  = (dg[0], dg[1]);
	
	let mut p: Vec<i32> = vec![];
	let mut c: Vec<i32> = vec![];
	for _ in 0..d {
		let pc = read_vec();
		p.push(pc[0]);
		c.push(pc[1]);
	}
	
	let mut ans = std::i32::MAX;
	
	for b in 0..(1 << d) {
		let mut sum = 0;
		let mut cnt = 0;
		let mut rmx = -1;
		for i in 0..d {
			if (b >> i) & 1 != 0 {
				sum += 100 * (i+1) * p[i as usize] + c[i as usize];
				cnt += p[i as usize];
			} else {
				rmx = i;
			}
		}
		
		if sum < g {
			let s = 100 * (rmx+1);
			let need = (g - sum + s - 1) / s;
			if need >= p[rmx as usize] {
				continue;
			}
			cnt += need;
		}
		ans = min(ans, cnt);
	}
	println!("{}", ans);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().split_whitespace().map(|e|
        e.parse().ok().unwrap()
    ).collect()
}

Measured memory_bytes: 4352
ans = 0
def ceil(a, b):
   return a // b + (a % b > 0)
big = 0
for _ in range(5):
    a = int(input())
    ans += ceil(a, 10) * 10
    if a % 10 != 0:
        big = max(big, 10-(a%10))

print(ans-big)




Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    int x,y;
    ll z;
    x = *min_element(all(a));
    y = *max_element(all(a));
    z = accumulate(all(a),0LL);
    cout << x sp y sp z << endl;
    return 0;
}


Measured memory_bytes: 3128
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int a = one.get(0);
		int b = one.get(1);
		if(a + b == 15 && a * b != 15){
			myout("+");
		}else if(a + b != 15 && a * b == 15){
			myout("*");
		}else{
			myout("x");
		}
	}
	//Method addition frame start



	//Method addition frame end
}


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

namespace ConsoleApp15
{
    class Class161
    {
        static void Main()
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NM[0], M = NM[1];
            if (N == M) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long int A[n] = {};
    long long int ans = 0;
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        if(a > n)
        {
            ans++;
        }
        else
        {
            A[a - 1]++;
        }
    }
    for(int i = 0;i < n;i++)
    {
        if(A[i] > (i + 1))
        {
            ans += (A[i] - (i + 1));
        }
        else if(A[i] < (i + 1))
        {
            ans += A[i];
        }
    }
    cout << ans << "\n";

    return 0;
}

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

#define MAXN 1000010
#define endl '\n'


using namespace std;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x;
    cin >> n >> x;
    while(true){
        if (x == 0 && n == 0) break;
        int count = 0;
        int third = n + 1;
        vector<int> seconds;
        for (int i = n; i > 1; --i) {
            third = n + 1;
            for (int j = i - 1; j > 1; --j) {
                if(i + j < x){
                    int r = x - (i + j);
                    if(r != i && r != j && r < j){
                        ++count;
                    }
                }
            }
        }
        cout << count << endl;
        cin >> n >> x;
    }

    return 0;
}


Measured memory_bytes: 3168
#include<iostream>
using namespace std; 
int main (){
  string a="Sunny" ,b="Cloudy" , c="Rainy" ;
  string str;
  cin>>str;
  if(str==a)cout<<b;
  else if(str==b)cout<<c;
  else cout<<a;
  return 0 ; 
}

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

int main(void) {
	int num, pre, slope = 0, count = 1;
	cin >> num;
	vector<int> vec(num);
	for (int i = 0; i < num; i++) cin >> vec.at(i);
	pre = vec.at(0);

	for (int i = 1; i < num; i++) {
		if (slope == 1) {
			if (pre > vec.at(i)) { slope = 0; count++; pre = vec.at(i); }
			else if (pre < vec.at(i)) { slope = 1; pre = vec.at(i); }
			//      else if(pre==vec.at(i)){ pre=vec.at(i); }
		}
		else if (slope == -1) {
			if (pre > vec.at(i)) { slope = -1; pre = vec.at(i); }
			else if (pre < vec.at(i)) { slope =0; count++; pre = vec.at(i); }
			//      else if(pre==vec.at(i)){ pre=vec.at(i); }
		}
    else if(slope==0){
      if(pre>vec.at(i)){ slope=-1;pre=vec.at(i); }
      else if(pre<vec.at(i)){ slope= 1;pre=vec.at(i); }
      //      else if(pre==vec.at(i)){ pre=vec.at(i); }
    }
	}

	cout << count << endl;
	return 0;

}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>//printf("%.15f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字)
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;
	
	int n;
	cin >> n;
	vector<pair<pair<string, int>,int>> a(n);
	rep(i, n) {
		cin >> a[i].first.first >> a[i].first.second;
		a[i].first.second *= -1;
		a[i].second = i + 1;
	}
	sort(a);
	rep(i, n) {
		cout << a[i].second << rt;
	}

	please AC;
}
//@domino解 参考AC

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

int main(void) {
    string S, T;
    int A, B;
    string U;

    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if(S == U)
        A--;
    else if (T == U)
        B--;

    cout << A << " " << B << endl;
    
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b, int mod)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}

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

#define N 100010
#define MOD 1000000007

struct comp {
    bool operator() (const pair<int, int> a, const pair<int, int> b) const
    {
        return a.ss > b.ss;
    }
};

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int n;
    cin >> n;
    int a[3];

    cin >> a[0] >> a[1] >> a[2];
    int dp[2][3] = {};
    dp[0][0] = a[0];
    dp[0][1] = a[1];
    dp[0][2] = a[2];

    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            cin >> a[j];
            dp[i % 2][j] = a[j] + max(dp[(i - 1) % 2][(j + 1) % 3], dp[(i - 1) % 2][(j + 2) % 3] );
        }
    }

    cout << *max_element(dp[(n - 1) % 2], dp[(n - 1) % 2] + 3);
    return 0;
}

Measured memory_bytes: 3624
n = int(input())

s = []
for _ in range(n):
    s += [''.join(map(str, (sorted(list(str(input()))))))]

import collections

c = collections.Counter(s)

from math import factorial

ans = 0

for x in c.values():
    if x >= 2:
        ans += factorial(x)//(factorial(x-2)*2)

print(ans)


Measured memory_bytes: 69208
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VII;
typedef pair<int,int> PII;

int A[200010]={};
int ans[200010]={};
VII T(200010,VI(0));

void dfs(int s){
  A[s]++;
  rep(i,T[s].size()){
    if(A[T[s][i]]==0){
      ans[T[s][i]]+=ans[s];
      dfs(T[s][i]);
    }
  }
}

int main(){
  int N,Q;
  cin>>N>>Q;
  VI A(N-1),B(N-1),P(Q),X(Q);
  rep(i,N-1) cin>>A[i]>>B[i];
  rep(i,Q) cin>>P[i]>>X[i];
  rep(i,N-1){
    T[A[i]-1].push_back(B[i]-1);
    T[B[i]-1].push_back(A[i]-1);
  }
  rep(i,Q) ans[P[i]-1]+=X[i];
  A[0]++;
  dfs(0);
  rep(i,N){
    if(i) cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
}


Measured memory_bytes: 24320
from math import *
from sys import stdin,stdout
input=stdin.buffer.readline

n=int(input())
d=n%10
if d==2 or d==4 or d==5 or d==7 or d==9:
	print("hon")
elif d==0 or d==1 or d==6 or d==8:
	print("pon")
else:
	print("bon")

Measured memory_bytes: 9240