akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include<map>
#include<unordered_set>
#include<queue>
#include<stack>
using namespace std;

constexpr int INF = 10000000;

using Matrix = vector<vector<int>>;

Matrix mat;

Matrix warshall_floyd(Matrix& mat,int n) { // nは頂点数
	for (int i = 0; i < n; i++)      // 経由する頂点
		for (int j = 0; j < n; j++)    // 開始頂点
			for (int k = 0; k < n; k++)  // 終端
				mat[j][k] = min(mat[j][k], mat[j][i] + mat[i][k]);
	return mat;
}

bool check(const Matrix&mat)
{
	for (size_t i = 0; i < mat.size(); i++)
	{
		for (size_t j = 0; j < mat.size(); j++)
		{
			if (i == j)continue;
			if (mat[i][j] == INF)
			{
				return true;
			}
		}
	}
	return false;
}

int main() {
	int n, m;
	cin >> n >> m;
	Matrix mat_origin;
	vector<pair<int, int>> pairs;
	for (size_t i = 0; i < n; i++)
	{
		mat_origin.emplace_back();
		for (size_t j = 0; j < n; j++)
		{
			mat_origin[i].emplace_back(INF);
		}
	}

	for (size_t i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		mat_origin[a][b] = 1;
		mat_origin[b][a] = 1;
		pairs.emplace_back(a, b);
	}



	int counter = 0;
	for (auto& pair:pairs)
	{
		Matrix mat = mat_origin;
		mat[pair.first][pair.second] = mat[pair.second][pair.first] = INF;
		mat = warshall_floyd(mat, n);
		if (check(mat))
		{
			counter++;
		}
	}


	cout << counter << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,a,b;
  int s;
  cin >> n;
  for(long long i=0;i<1000010;i++){
    if(i*i>n){
      s=i;
      break;
    }
  }
  for(int i=0;i<s;i++){
    if(n%(s-i)==0){
      a = s-i;
      b = n/(s-i); 
      break;
    }
  }
  cout << a+b-2 << endl;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
const int N=1e5+5;
struct edge
{
	 int w,u,v;
}e[2*N];
bool cmp(const edge a,const edge b)
{
	return a.w<b.w;
}
int f[N];
int Find(int x)
{
	 if(x!=f[x])f[x]=Find(f[x]);
	 return f[x];
}
void Union(int a,int b)
{
	 int x=Find(a);
	 int y=Find(b);
	 if(x!=y)f[x]=y;
}
int main()
{
	rep(i,0,N)
	f[i]=i;
  int n=rr,m=rr;
  int num=0;
  rep(i,0,m)
  {
  	 e[i].u=rr;
  	 e[i].v=rr;
  	 e[i].w=rr;
  	 e[i].w=0;
  	 num++;
  }
  
  rep(i,0,n)
  {
  	 e[m+i].u=n+1;
  	 e[m+i].v=i+1;
  	 e[m+i].w=1;
  	 num++;
  }
  sort(e,e+num,cmp);
  ll ans=0;
  rep(i,0,num)
  { 
  int u=e[i].u,v=e[i].v;
  	 if(Find(u)!=Find(v))
  	 {
  	 	 ans+=e[i].w;
  	 //	 printf("%d-->%d %d\n",u,v,e[i].w);
  	 	 Union(u,v);
	   }
  }
  cout<<ans;
  
}




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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;

signed main(){
    cin>>N;

    set<int>s;
    while(N--){
        int a;cin>>a;
        if(s.find(a)!=s.end())s.erase(a);
        else s.insert(a);
    }
    cout<<s.size()<<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000000000
using ll = long long;


int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> p(m),y(m);
  vector<vector<ll>> py(n);
  rep(i,m){
    cin >> p.at(i) >> y.at(i);
    py.at(p.at(i)-1).push_back(y.at(i));
  }
  rep(i,n)sort(py.at(i).begin(),py.at(i).end());
  rep(i,m)printf("%012lld\n",ll(p.at(i))*1000000+int(lower_bound(py.at(p.at(i)-1).begin(),py.at(p.at(i)-1).end(),y.at(i))-py.at(p.at(i)-1).begin())+1);
  
  return 0;
}


Measured memory_bytes: 8576
'use strict'
function main(input: string) {
    const u: number[] = input.split('\n')[1].split(' ').map(Number).sort((a,b) => {return a - b});
    const r = u.reduce((acc, cur) => (acc + cur) / 2);
    console.log(r);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

i32 n, c_siz, x,y, tmp, ans, Mod;
vii d, c;
i32 rcd[4][33];  // rcd[i][j] : i mod(3)を　j 色にするときの合計コスト
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    cin >> n >> c_siz;
    c.resize(n, vi(n));
    d.resize(c_siz, vi(c_siz));
    rep(i,c_siz) rep(j,c_siz) cin >> d[i][j];
    rep(i,n) rep(j,n) cin >> c[i][j];

    // 0, 1, 2 (mod3) でそれぞれ選ぶ色を全探索する

    memset(rcd, 0, sizeof(rcd));
    rep(color, c_siz) {  // j色
        rep(i,n) rep(j,n) {
            Mod = (i+1 + j+1)%3;
            rcd[Mod][color] += d[c[i][j]-1][color];
        }
    }

    ans = inf;
    rep(i,c_siz) rep(j,c_siz) rep(k,c_siz) if(i!=j && j!=k && k!=i) {
        tmp = rcd[0][i] + rcd[1][j] + rcd[2][k];
        chmin(ans, tmp);
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b;
  cin >> a >> b;

  cout << (b-a) * (b-a+1) / 2 - b << endl;

  return 0;
}


Measured memory_bytes: 3640
=begin
中間試験、期末試験のいずれかを欠席した場合成績は F。
中間試験と期末試験の合計点数が 80 以上ならば成績は A 。
中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。
中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。 ただし、再試験の点数が 50 以上ならば成績は C。
中間試験と期末試験の合計点数が 30 未満ならば成績は F。
=end

loop do
    m, f, r  = gets.split(" ").map(&:to_i)
    if m + f + r == -3 then
        break
    end
    
    s = ""
    if m == -1 || f == -1 then
        s = "F"
    elsif m + f >= 80 then
        s = "A"
    elsif m + f >= 65 then
        s = "B"
    elsif m + f >= 50 then
        s = "C"
    elsif m + f >= 30 then
        s = "D"
        if r >= 50 then
            s = "C"
        end
    else
        s = "F"
    end
    
    print s, "\n"
end



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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/

vector<pair<ull, ull> > prime_factorize(ull N) {
    vector<pair<ull, ull> > res;
    for (ull a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ull ex = 0; // 指数
 
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
 
        // その結果を push
        res.push_back({ a, ex });
    }
 
    // 最後に残った数について
    if (N != 1) res.push_back({ N, 1 });
    return res;
}

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    vector<pair<ull, ull>> tmpPrime;
    ull numDivisor;
    int ans = 0;
    for(int i=1; i<=N; i+=2) {
        numDivisor = 1;
        tmpPrime = prime_factorize((ull)i);
        for(auto& p : tmpPrime) {
            numDivisor *= (p.second + 1);
        }
        if (numDivisor == 8) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X, Y, A, B, C = map(int, readline().split())
    P = list(map(int, readline().split()))
    Q = list(map(int, readline().split()))
    R = list(map(int, readline().split()))

    P.sort(reverse=True)
    Q.sort(reverse=True)

    apple = P[:X] + Q[:Y] + R
    apple.sort(reverse=True)

    print(sum(apple[: X + Y]))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 29020
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int X, A, B;
  cin >> X >> A >> B;
  X -= A;
  cout << X - X / B * B << endl;
  return 0;
}


Measured memory_bytes: 3608
from  collections import deque
K = int(input())
# 素因数分解
# 戻り値: リスト
def prime_factor(n):
    ass = deque
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass

# 最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

ans = 0
d = {}
for a in range(1, K+1):
    for b in range(1, K+1):
        t = (a, b)
        d[t] = gcd(a, b)
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            ab = d[(a, b)]
            ans += d[(ab, c)]
print(ans)

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

using namespace std;

int main(){
  string str;
  cin >> str;
  
  if(str.at(0) == str.at(1) && str.at(1) == str.at(2)){
  	cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 384
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            int A = 0;
            int B = 0;
            while(true)
            {
                if(X >= 500)
                {
                    A++;
                    X  -= 500;
                }
                else
                {
                    break;
                }
            }
            while (true)
            {
                if(X >= 5)
                {
                    B++;
                    X -= 5;
                }
                else
                {
                    break;
                }
            }
            int ans = (A * 1000) + (B * 5);
            Console.WriteLine(ans);
        }
    }
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,m,lmax=0,rmin=INF,ans=0;
  cin >> n >> m;
  vector<ll> l(m),r(m);
  rep(i,m){
    cin >> l[i] >> r[i];
    lmax = max(lmax, l[i]);
    rmin = min(rmin, r[i]);
  }
  if(lmax <= rmin){
    REP(i,lmax,rmin+1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		
		if (n % 500 <= a ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
}

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

using namespace std;

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

  int n;
  cin >> n;
  int two = 0, four = 0, other = 0;
  int e;
  for (int i = 0; i < n; ++i) {
    cin >> e;
    if (e % 4 == 0)
      ++four;
    else if (e % 2 == 0)
      ++two;
    else
      ++other;
  }
  string out[] = {"No", "Yes"};
  cout << out[other <= four + (0 == two)] << "\n";
}


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

int mod(int N){
    int cnt=0;
    while(N<0||N>=2){
        if(N>0){
            N-=2;
            cnt--;
        }else {
            N+=2;
            cnt++;
        }
    }
    return cnt;
}

int main(){
    int N;
    cin>>N;
    char S[256]={'0'};
    int i=0;
    

    while(N){
        S[i]=(abs(N)%2)+'0';
        i++;
        N=mod(N);
    }
    if(i){
         for(int j=i;j>0;j--){
        cout<<S[j-1];
        }
    }else cout<<'0';
   
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
list_penalties = {str(i): 0 for i in range(1, N+1)}
list_correct = {str(i): 0 for i in range(1, N+1)}
total_penalty = 0
for _ in range(M):
  p, s = input().split()
  if list_correct[p] == 0:
    if s == "WA": list_penalties[p] += 1
    elif s == "AC":
      list_correct[p] = 1
      total_penalty += list_penalties[p]
print(sum(value for key, value in list_correct.items()), total_penalty)

Measured memory_bytes: 31848
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long ans=0;
    int n,i=0,a[200009];
    for(scanf("%d",&n); i<n; ++i) scanf("%d",a+i),a[i]-=i;
    for(sort(a,a+n),i=0; i<n; ++i) ans+=abs(a[n/2]-a[i]);
    printf("%lld\n",ans);
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		char c[] = str.toCharArray();
		String ans = "No";
		sc.close();
		if (c[2]==c[3] && c[4]==c[5]) {
			ans = "Yes";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
def main():
    N = int(input())
    h = [int(i) for i in input().split()]
    ans = 0
    mul = h[1:N-1].count(0) + 1
    for i in range(max(h)):
        ans += 1 * mul
        z_cnt = 0
        flag = False
        for j in range(N):
            h[j] = (h[j]-1 if h[j] != 0 else h[j]) 
            if h[j] != 0:
                flag = True
            elif j == N-1 and h[j] == 0 and not flag:
                z_cnt -= 1
            elif j != 0 and j != N-1 and h[j] == 0 and flag:
                z_cnt += 1
                flag = False
        mul = z_cnt + 1


    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 39408
# abc165_a.py
# https://atcoder.jp/contests/abc165/tasks/abc165_a

# ★ WA:5
# sub1_02.txt
# sub1_03.txt
# sub1_05.txt
# sub1_06.txt
# sub1_07.txt

# A - We Love Golf /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点: 100点

# 問題文
# ジャンボ高橋君はゴルフの練習をすることにしました。
# ジャンボ高橋君の目標は飛距離を Kの倍数にすることですが、ジャンボ高橋君の出せる飛距離の範囲は A 以上 B以下です。
# 目標の達成が可能であれば OK と、不可能であれば NG と出力してください。

# 制約
#     入力はすべて整数
#     1≤A≤B≤1000
#     1≤K≤1000

# 入力
# 入力は以下の形式で標準入力から与えられる。
# K
# A B

# 出力
# 目標の達成が可能であれば OK と、不可能であれば NG と出力せよ。

# 入力例 1
# 7
# 500 600

# 出力例 1
# OK

# 7の倍数のうち、たとえば 567 が 500 以上 600以下の範囲にあります。

# 入力例 2
# 4
# 5 7

# 出力例 2
# NG

# どんな 4の倍数も、5 以上 7以下の範囲にはありません。

# 入力例 3
# 1
# 11 11

# 出力例 3
# OK


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    K = int(lines[0])
    A, B = list(map(int, lines[1].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    # if (B+1-A) < K:
    #     result = 'NG'
    # else:
    #     result = 'OK'
    result = 'NG'
    for i in range(A, B+1):
        if i % K == 0:
            result = 'OK'

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['7', '500 600']
        lines_export = ['OK']
    if pattern == 2:
        lines_input = ['4', '5 7']
        lines_export = ['NG']
    if pattern == 3:
        lines_input = ['1', '11 11']
        lines_export = ['OK']
    if pattern == -1:
        lines_input = ['1000', '1000 1000']
        lines_export = ['OK']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    if FLAG_LOG:
        log(f'lines_input=[{lines_input}]')
        log(f'lines_export=[{lines_export}]')
        log(f'lines_result=[{lines_result}]')
        if lines_result == lines_export:
            log('OK')
        else:
            log('NG')
    finished = time.time()
    duration = finished - started
    log(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9160
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef unsigned long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N;
    cin >> N;
    N--;
    pr((N*(1+N))/2);
}

Measured memory_bytes: 256
N = int(input())
A = []
for _ in range(N):
    S = []
    for _ in range(int(input())):
        x, y = map(int, input().split())
        S.append((x - 1, y))
    A.append(S)

def calc(state):
    ret = 0
    for i, S in enumerate(A):
        if (state & (1 << i)) == 0:
            continue
        ret += 1
        for x, y in S:
            if (state & (1 << x)) != (y << x):
                return 0
    return ret

ans = 0
for state in range(1 << N):
    ans = max(ans, calc(state))
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin>>N;
    vector<int> X(N);
    for(int i=0;i<N;i++){
        cin>>X[i];
    }
    int minimum=900000;
    int ans=0;
    for(int i=1;i<=1000;i++){
        int wa=0;
        for(int j=0;j<N;j++){
            wa=wa+(abs(X[j]-i))*(abs(X[j]-i));
        }
        minimum=min(minimum,wa);
    }
    cout<<minimum;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

q = deque(list(input()))
Q = int(input())

flg = 0
for _ in range(Q):
    i, *x = input().split()
    if i == "1":
        flg = 1 - flg
    else:
        f, c = x
        if flg == 0:
            if f == "1":
                q.appendleft(c)
            else:
                q.append(c)
        else:
            if f == "1":
                q.append(c)
            else:
                q.appendleft(c)

if flg == 0:
    print("".join(q))
else:
    print("".join(reversed(q)))


Measured memory_bytes: 103576
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string N;
int ans;

int main()
{
	in >> N;
	rep(i, N.length())
	{
		ans += N[i] - '0';
	}
	out << (ans == 1 ? 10 : ans) << std::endl;
	return 0;
}


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

using namespace std;
using uint = unsigned int;
using int64 = long long;
using i64 = int64;
using uint64 = unsigned long long;
using vint = vector<int>;
using vint64 = vector<int64>;
template<typename T>
using p_que = priority_queue<T>;
#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rep1(i,N) for(int i=1;i<=(int)(N);++i)
#define fs first
#define sc second
#define eb emplace_back
#define all(x) x.begin(),x.end()

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

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

template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U> p) {
	return os << "P(" << p.first << ", " << p.second << ")";
}

template<class T, class U> ostream& operator<<(ostream& os, const map<T, U>& mp) {
	os << "{";
	for (auto& e : mp) os << e << " ";
	return os << "}";
}

void Main();
signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
}

/* Cut from here! */

template <uint mod> struct ModInt {
	uint x;
	ModInt(int64_t y = 0) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
	ModInt& operator+=(const ModInt& p) {
		if ((x += p.x) >= mod) x -= mod;
		return *this;
	}
	ModInt& operator-=(const ModInt& p) {
		x = (int)(1ll * x * p.x % mod);
		return *this;
	}
	ModInt& operator/=(const ModInt& p) {
		*this *= p.inverse();
		return *this;
	}
	ModInt operator-() const {
		return ModInt(-x);
	}
	ModInt operator+(const ModInt& p) const {
		return ModInt(*this) += p;
	}
	ModInt operator-(const ModInt& p) const {
		return ModInt(*this) -= p;
	}
	ModInt operator*(const ModInt& p) const {
		return ModInt(*this) *= p;
	}
	ModInt operator/(const ModInt& p) const {
		return ModInt(*this) /= p;
	}
	bool operator==(const ModInt& p) const {
		return x == p.x;
	}
	bool operator!=(const ModInt& p) const {
		return x != p.x;
	}
	ModInt inverse() const {
		int a = x, b = mod, u = 1, v = 0, t;
		while (b > 0) {
			t = a / b;
			swap(a -= t * b, b);
			swap(u -= t * v, v);
		}
		return ModInt(u);
	}
	ModInt pow(int64_t n) const {
		ModInt ret(1), mul(x);
		while (n > 0) {
			if (n & 1) ret *= mul;
			mul *= mul;
			n >>= 1;
		}return ret;
	}
	friend ostream& operator<<(ostream& os, const ModInt& p) {
		return os << p.x;
	}
};


//#define int long long
const uint MOD = 1e9 + 7;

void Main() {
	int N; cin >> N;
	string s, t; cin >> s >> t;

	using mint = ModInt<MOD>;
	vector<mint> dp(N);
	auto sum = make_v(N, 30, mint(0));

	dp[0] = 1;
	sum[0][s[0] - 'a'] = 1;
	for (int i = 1; i < N; ++i) {
		char c = t[i];
		dp[i] += sum[i - 1][c - 'a'];
		char e = s[i];
		sum[i][e - 'a'] += dp[i];
		for (char ch = 'a'; ch <= 'z'; ++ch) {
			sum[i][ch - 'a'] += sum[i - 1][ch - 'a'];
		}
	}

	cout << dp[N - 1] << endl;
}


Measured memory_bytes: 18200
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, L,tmp;
	cin >> N >> L;
	VI A(N);
	VI ans;
	bool F = false;
	REP(i, N) {
		cin >> A[i];
	}
	REP(i, N - 1) {
		if (A[i] + A[i + 1] >= L) {
			F = true;
			tmp = i;
			break;
		}
	}
	if (!F) {
		cout << "Impossible" << endl;
	}
	else {
		cout << "Possible" << endl;
		eFOR(i, 1, tmp) {
			cout << i << endl;
		}
		for (int i = N-1; i > tmp; i--) {
			cout << i << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 1664
#include <stdio.h>
int solve(int,int);
int n,A[200];
int main(){
  int i,j,q,B[200];
  scanf("%d",&n);    
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&B[i]);
  }
  
  for(i=0;i<q;i++){
    if(solve(0,B[i])==1)
      printf("yes\n");
    else
      printf("no\n");
  }
}
/*********************************************/
int solve(int i,int m){
  int res;
  if(m==0){
    return 1;
  }
  if(i>=n){
    return 0;
  }
  res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}



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

int main() {
  int N; cin >> N;
  vector<int> a(N), c(10001, 0);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    ++c[a[i]];
  }
  int ans = 0;
  for (int i = 1; i < N; ++i) {
    if (a[i - 1] != a[i]) continue;
    ++ans;
    for (int j = 1; j <= 10000; ++j) {
      if (c[j]) continue;
      ++c[j];
      a[i] = j;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define db(...) " [" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "] "
using ii=long long;
int MAX = 1e6;
int main()
{
    ii N;
    cin >> N;
    ii O = N;
    vector<ii> fact;
    for (ii x = 2; x * x <= N; ++x) {
        while (N % x == 0) {
            fact.push_back(x);
            N /= x;
        }
    }
    if (N != 1) {
        fact.push_back(N);
    }
    sort(all(fact));
    vector<pair<ii, int>> occ;
    for (int i = 0; i < (int) fact.size(); ++i) {
        int j = i;
        while (j + 1 < (int) fact.size() && fact[i] == fact[j + 1]) ++j;
        occ.emplace_back(fact[i], j - i + 1);
        i = j;
    }
    ii res = 1e18;
    function<void(int, ii, ii)> gen = [&](int x, ii A, ii B) {
        if (x == (int) occ.size()) {
            res = min(res, A + B - 2);
            return;
        }
        for (int i = 0; i <= (int) occ[x].second; ++i) {
            gen(x + 1, A, B);
            A *= occ[x].first;
            B /= occ[x].first;
        }
    };
    gen(0, 1, O);
    cout << res << "\n";
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    from collections import deque

    N,M = map(int,input().split())
    dp = [-1]*N
    ad = [deque() for _ in range(N)]
    num = [0]*N
    for _ in range(M):
        x,y = map(int,input().split())
        x -= 1; y -= 1
        ad[x].append(y)
        num[y] += 1

    L = []
    S = deque()

    for v in range(N):
        if num[v] == 0:
            S.append(v)
            dp[v] = 0

    while S:
        v = S.popleft()
        L.append(v)
        for _ in range(len(ad[v])):
            nv = ad[v].popleft()
            num[nv] -= 1
            if num[nv] == 0:
                S.append(nv)
                if dp[nv] < dp[v] + 1:
                    dp[nv] = dp[v] + 1

    ans = max(dp)
    print(ans)

main()

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  string s;
  cin >> s;
  YesorNo(s.find("7") != string::npos);
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std; 
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long ll; 
const ll MOD = 1000000007;

int main()  
{ 
	FAST_INP;
	ll n,d,x,y;
	cin >> n >> d;
	int ans=0;
	for (int i=0; i<n; i++) {
		cin >> x >> y;
		if(x*x+y*y<=d*d) ans++;
	}
	cout << ans << endl;
    return 0;
} 

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

int main() {
	string s; cin >> s;
	if(s.size()==2) {
		if(s[0]==s[1]) {
			cout << 1 << " " << 2 << endl;
			return 0;
		}
	}
	for(int i=0;i<s.size()-2;++i) {
		if(s[i]==s[i+1]||s[i]==s[i+2]||s[i+1]==s[i+2]) {
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	
	return 0;
}

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

int main()
{
	string s;
	cin >> s;
	char A[3];
	int sum = 0;
	for (int bit = 0; bit < (1<<4); bit++){
		sum = (s[0]-'0');
		for (int i = 0; i < 3; i++){
			if (bit & (1<<i)){
				sum -= (s[i+1]-'0');
				A[i] = '-';
			}
			else{
				sum += (s[i+1]-'0');
				A[i] = '+';
			}
		}
		if (sum == 7) {
			cout << s[0] << A[0] << s[1] << A[1] << s[2] << A[2] << s[3] <<"=7" <<  endl;
			return 0;
		}
	}
}




Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define INFTY 1000000001

void merge(int[], int, int, int);
void mergeSort(int[], int, int);

int count=0;

int main()
{
  int n,i;
  int left,right,mid;
  int A[500000];

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  left = 0;
  mid = i/2;
  right = i;

  mergeSort(A,left,right);
  
  for(i=0; i<n-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n%d\n",A[i],count);
  

  return 0;
}

void merge(int A[], int left, int mid, int right)
{
  int n1, n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;

  int L[n1];
  int R[n2];

  for(i=0; i<n1; i++)
    L[i] = A[left+i];

  for(i=0; i<n2; i++)
    R[i] = A[mid+i];

  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for(k=left; k<right; k++){
    if(L[i] <= R[j]){
      count++;
      A[k] = L[i];
      i += 1;
    }
    else {
      count++;
      A[k] = R[j];
      j += 1;
    }
  }
}

void mergeSort(int A[], int left, int right)
{
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}



Measured memory_bytes: 6520
#include <stdio.h>
int main(){
	int x,y;

	scanf("%d %d",&x,&y);
	if(x>y)
		printf("a > b\n");
	if(x==y)
		printf("a == b\n");
	if(x<y)
		printf("a < b\n");

	return 0;
}

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

int sort(const void *a, const void *b){
    return *(int*)b-*(int*)a ;
}

int main(void){
    int n,k,sum=0;;
    scanf("%d%d",&n,&k);
    int a[n],count[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        count[i]=0;
    }
    for (int i=0; i<n; i++){
        count[a[i]-1]++;
    }
    qsort (count,n,sizeof(int),sort);
    for (int i=0; i<k; i++){
        sum+=count[i];
    }
    if (sum==n){
        printf ("0\n");
    } else {
        printf ("%d\n",n-sum);
    }
	return 0 ;
}

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

int main(){
    char s[100];
    cin>>s;
    string ans;
    if(s[5]=='0'&&s[6]-'0'<5) ans="Heisei";
    else ans="TBD";
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19

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

    vector<double> vs(n);
    for (int i = 0; i < n; i++) {
        cin >> vs[i];
    }
    sort(vs.begin(), vs.end());
    // double ans = vs[0];
    // for (int i = 1; i < n; i++) {
    //     ans = (ans + vs[i]) / 2;
    // }

    double ans = accumulate(vs.begin() + 1, vs.end(), vs[0], [](double a, double b) {
        return (a + b) / 2.0;
    });
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, i;

	cin >> n;

	for (i = n; i >= 1; i--) {
		if ((int)sqrt(i) * (int)sqrt(i) == i) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = int(1e5 + 5);
#define REP(i, n) for (int i = 0; i < n; i++)

vector<int> g[MAX_N], gr[MAX_N];
int dp[MAX_N], id[MAX_N]; // dp[i]:頂点iからスタートしたときの最長経路
bool visited[MAX_N];

void dfs(int cur, int &k){
    visited[cur] = true;
    for(auto to : g[cur]){
        if(visited[to])continue;
        dfs(to, k);
    }
    id[k] = cur;
    ++k;
}


int main() {
    int n, m;
    cin >> n >> m;
    REP(i,m){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
        gr[y].push_back(x);
    }
    int k=0;
    REP(i,n){
        if(visited[i])continue;
        dfs(i,k);
    }
    REP(i,n){
        for(auto j : gr[id[i]]){
            dp[j] = max(dp[j], dp[id[i]]+1);
        }
    }
    int ans = 0;
    REP(i,n) ans = max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14080
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(void){
	vector<int> a(100);
	int N;
	cin >> N;
	int _max = -99999999;
	int _min = 99999999;
	REP(i, N)
	{
		cin >> a[i];
		_max = max(_max, a[i]);
		_min = min(_min, a[i]);
	}
	int d = 0;
	int index = 0;
	cout << 2 * N  - 1 << endl;
	if (abs(_max) > abs(_min))
	{
		vector<int>::iterator iter = max_element(a.begin(), a.end());
		index = distance(a.begin(), iter);
		for (int i = 0; i < N; i++)
		{
			cout << index+1 << " " << i+1 << endl;
		}
		for (int i = 0; i < N-1; i++){
			cout << i+1 << " " << i + 2 << endl;
		}
	}
	else if(abs(_max)<= abs(_min)){
		vector<int>::iterator iter = min_element(a.begin(), a.end());
		index = distance(a.begin(), iter);
		for (int i = 0; i < N; i++)
		{
			cout << index+1 << " " << i+1 << endl;
		}
		for (int i = 0; i < N - 1; i++)
		{
			cout << N-i << " " << N-i-1 << endl;
		}
	}
	return 0;
}



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

typedef long long int ll;
typedef pair<ll,ll> P;
//cout<<fixed<<setprecision(15);

//様子見！！！！！


int main(){
    int d;
    cin>>d;
    int mmax=0;int maxi=0;
    for(int i=0;i<26;i++){
        int tmp;
        cin>>tmp;
        if(tmp>mmax){
            mmax=tmp;
            maxi=i+1;
        }
    }
    for(int i=0;i<365;i++){
        cout<<maxi<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            int N = int.Parse(Console.ReadLine());
            Console.WriteLine(N < 1000 ? "ABC" : "ABD");


            //Console.Out.Flush();
            
        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}



Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  vector<string> s(a);
  for(int i = 0;i<a;i++)
    cin >> s.at(i);
  sort(s.begin(),s.end());
  for(int i = 0;i<a;i++)
    cout << s.at(i);
  cout << endl;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

LL calc_xor(LL N){
    if(N % 2 == 1) return ((N+1) / 2) % 2;

    return ((N/2)%2) ^ N;     
}

void solve(long long A, long long B){
    if(A == B) {
        cout << A << endl;
        return;
    }
    
    if(A == 0) {
        if(B%4 == 1) cout << 1 << endl;
        else if(B%4 == 2) cout << B+1 << endl;
        else if(B%4 == 3) cout << 0 << endl;
        else cout << B << endl;
        return;
    }

    cout << (calc_xor(A-1) ^ calc_xor(B)) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#84b
A,B = map(int, input().split())
S = str(input())

if S[A]!="-":
    print("No")
else:
    for i in range(len(S)):
        if (i<A or i>A) and S[i].isdecimal()!=True:
            print("No")
            break
    else:
        print("Yes")

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

c = [[0 for _ in range(10)] for __ in range(10)]
for i in range(1, n+1):
    str_i = str(i)
    head = int(str_i[0])
    tail = int(str_i[-1])
    c[head][tail] += 1

cnt = 0
for i in range(10):
    for j in range(10):
        cnt += c[i][j] * c[j][i]

print(cnt)

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

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

int main(){
  string s,t;
  cin>>s>>t;
  int slen=s.length();
  int tlen=t.length();
  int dp[3010][3010];
  rep(i,slen+1)rep(j,tlen+1){
    if(s[i]==t[j]){
      dp[i+1][j+1]=dp[i][j]+1;
    }
    else{
      dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
    }
  }
  //復元
  string ans="";
  int i=slen;
  int j=tlen;
  while(i>=0 && j>=0){
    if(dp[i][j]==dp[i-1][j]){
        i--;
      }
      else if(dp[i][j]==dp[i][j-1]){
        j--;
      }
    else{
      ans=s[i-1]+ans;
      i--;
      j--;
    }
  }
  cout<<ans<<endl;
  return 0;
}


      

Measured memory_bytes: 39000
def foo(x,y,z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

N = int(input())

A = [0 for i in range(10050)]

for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            tmp = foo(i,j,k)
            if tmp < 10050:
                A[tmp] += 1

for i in range(1,N+1):
    print(A[i])

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

int main(){
  int n; 
  cin >> n;
  map<ll, int> mp;
  while(cin >> n){
    if(mp.count(n)){
      mp.erase(n);
    } else {
      mp[n] = 1;
    }
  }
  cout << mp.size() << endl;
}


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

N, M, X, Y = [int(c) for c in input().split()]
xls = [int(x) for x in input().split()]
yls = [int(c) for c in input().split()]
if max (xls) < min(yls) and Y > max(xls) and X < min(yls):
    print('No War')
else:
    print('War')

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

int main() {
  string s;
  cin>>s;
  int ans=0;
  if(s=="SSS")
    cout<<"0"<<endl;
  else if(s=="RRR")
    cout<<"3"<<endl;
  else if(s=="RRS"||s=="SRR")
    cout<<"2"<<endl;
  else
    cout<<"1"<<endl;
}


Measured memory_bytes: 3624
#define SUBMIT

// https://beta.atcoder.jp/contests/abc105

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <map>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_N = 100000;
//ui64 dp[MAX_N + 1][MAX_N + 1];
ui64 dp[MAX_N + 1];

int main() {
    int N, M;
#ifdef SUBMIT
    cin >> N >> M;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
#else
    N = 13, M = 17;
    vector<int> A {29, 7, 5, 7, 9, 51, 7, 13, 8, 55, 42, 9, 81};
//    N = 3, M = 2;
//    vector<int> A {4, 1, 5};
#endif
    map<ui64, ui64> mod_to_count;

    ui64 s = 0;
    mod_to_count[s % M]++;
    for (int i = 0; i < N; ++i) {
        s += A[i];
        mod_to_count[s % M]++;
    }

    ui64 ans = 0;
    for (const auto& p : mod_to_count) {
//        cout << "(" << p.first << ", " << p.second << ")" << endl;
        ans += p.second * (p.second - 1) / 2;
    }

    cout << ans << endl;
    return 0;
//    for (int r = 1; r < N; ++r) {
//        s += dp
////        cout << dp[r] << endl;
//    }
//
//    ui64 ans = 0;
//    for (int l = 0; l < N; ++l) {
//        for (int r = l + 1; r < N + 1; ++r) {
////            cout << dp[r] - dp[l] << endl;
//            if ((dp[r] - dp[l]) % M == 0) {
//                ans++;
//            }
//        }
//    }
//
//    cout << ans << endl;
//    return 0;
}

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


int main()
{
   ll w,h,x,y;
   cin>>w>>h>>x>>y;
   int flag = 0;
   if(2*x == w && 2*y == h)
      flag = 1;
   double ans = (w*h)/2.0;
   cout<<fixed<<setprecision(9)<<ans<<" "<<flag;
   return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long N, X, Y;
long long D[2002] = {0};

long long dist(int i, int j){
	if(j <= i) return -1;
	long long d1 = abs(j - i);
	long long d2 = abs(X - i) + 1 + abs(j - Y);
	return min(d1, d2); 
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> X >> Y;

	for(int i=1; i<=N-1; i++){
		for(int j=i+1; j<=N; j++){
			long long d = dist(i, j);
			D[d]++;
		}
	}
	for(int i=1; i<N; i++){
		printf("%lld\n", D[i]);
	}
	return 0;
}

Measured memory_bytes: 3748