akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #pragma comment(linker, "/STACK:2000000")
  #pragma comment(linker, "/HEAP:2000000")
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  int deg[200005]={0};
  vector<int> adj[200005];
  bool vis[200005];
  vector<int>v; 
  int32_t main()
  {        
    IOS

    int a,b;
    cin>>a>>b;
    
    if(a==b)
    {
      cout<<"1";
    }
    else if((a+b)%2==0)
    {
      cout<<(a+b)/2;
    }
    else
    {
      cout<<"IMPOSSIBLE";
    }
    return 0;
} 

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
int main(){
    int a,b;
    cin>>a>>b;
    REP(i,max(a,b)){
        cout<<min(a,b);
    }
    cout<<endl;
}

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

int main(){
    long long int n, m;
    cin >> n >> m;
    if(n > m) swap(n,m);

    if(n == 1 && m == 1) cout << 1 << endl;
    if(n == 1 && m != 1) cout << m - 2 << endl;
    if(n == 2) cout << 0 << endl;
    if(n >= 3) cout << (n-2) * (m-2) << endl;
    return 0;
}

Measured memory_bytes: 256
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(s[K - 1])

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<int>> coord(N + 10, vector<int>(N + 10, 0));
    vector<vector<int>> sum_x(N + 10, vector<int>(N + 10, 0));

    rep(i, M) {
        int l, r;
        cin >> l >> r;
        coord[l][r]++;
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            sum_x[i][j] += sum_x[i][j - 1] + coord[i][j];
        }
    }

    rep(i, Q) {
        int p, q;
        cin >> p >> q;
        int sum = 0;
        for (int j = p; j <= q; j++) {
            sum += sum_x[j][q] - sum_x[j][p - 1];
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 2944
import sys

s, t = sys.stdin.readline().split()
a, b = map(int, sys.stdin.readline().split())
u = sys.stdin.readline().rstrip()

def main(a, b):
    if u == s: a -= 1
    else: b -= 1
    print(a, b)

if __name__ ==  '__main__':
    main(a, b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define For(i,l,r) for (register int i=l; i<=r; i++)
using namespace std;
typedef unsigned long long LL;
typedef signed long long ll;
template <typename T>
inline void read(T &x) {
	char c = getchar(); int w = 1; x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int n, a[100055];
int main() {
	read(n);
	For(i,1,n) read(a[i]);
	//bool p = 0;
	a[n+1] = 2000000000;
	int last = 1, key = a[1], ans = 0;
	For(i,2,n+1) {
		//if (p) {
			if (a[i] >= a[i-1]) {
				ans = max(ans, i-last-1);
				if (a[i] - a[i-1]) last = i, key = a[i];
			}
		//}
	}
	cout << ans;
	getchar();
	return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define MOD 1000000007

ll pows(ll a, ll b)
{
  ll ans = 1;
  ll ks = a;
  ll left = b;
  while(left > 0)
  {
    if(left%2 == 1)
    {
      ans = ans*ks%MOD;
    }
    left /= 2;
    ks = ks*ks%MOD;
  }
  return ans;
}

ll mod_inv(ll a)
{
  return pows(a,MOD-2);
}

int main()
{
  ll k;
  cin >> k;
  string s;
  cin >> s;
  ll sl = s.size();
  ll i;
  ll ans = 0;
  ll sck = 1;
  for(i=0;i<=k;i++)
  {
    if(i > 0)
    {
      sck = sck*(sl+i-1)%MOD;
      sck = sck*mod_inv(i)%MOD;
    }
    ans += sck*pows(25,i)%MOD*pows(26,k-i)%MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5324
arr = []
arr.append(list(map(int, input().split())))
arr.append(list(map(int, input().split())))
arr.append(list(map(int, input().split())))

def checker(arr):
    if arr[0][0] == arr[0][1] == arr[0][2] == "X":
        return True
    if arr[1][0] == arr[1][1] == arr[1][2] == "X":
        return True
    if arr[2][0] == arr[2][1] == arr[2][2] == "X":
        return True
    if arr[0][0] == arr[1][0] == arr[2][0] == "X":
        return True
    if arr[0][1] == arr[1][1] == arr[2][1] == "X":
        return True
    if arr[0][2] == arr[1][2] == arr[2][2] == "X":
        return True
    if arr[0][0] == arr[1][1] == arr[2][2] == "X":
        return True
    if arr[0][2] == arr[1][1] == arr[2][0] == "X":
        return True
    return False

for i in range(int(input())):
    a = int(input())
    for i in range(3):
        for j in range(3):
            if arr[i][j] == a:
                arr[i][j] = "X"
    
if checker(arr): print("Yes")
else: print("No")

Measured memory_bytes: 9200
#include <stdio.h>
#include <math.h>
int main()
{
  int i;
 
  /* 自然数 */
  int number;
 
  /* 判定フラグ */
  int flag = 0;
 
  /* 自然数の入力 */
  scanf("%d", &number);
 
  for( i=2;i<=sqrt(number);i++ ) {
    if( number%i==0 ) {
    number++;
      i=1;
    }
  }

  /* 判定結果を出力 */
printf("%d",number);
    return 0;
}


Measured memory_bytes: 128
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	auto a = IN<string>();
	auto b = IN<string>();
	auto c = IN<string>();
	if (a[SIZE(a) - 1] == b[0] && b[SIZE(b) - 1] == c[0])
		print("YES");
	else
		print("NO");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

#include <iostream>
using namespace std;

const long long MAX = 200005;
const long long MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    COMinit();
    int N, M, K;
    cin >> N >> M >> K;

    long long cur = M;
    long long ans = 0;
    for (int x = N - 1; x >= 0; --x)
    {
        if (x <= K)
        {
            long long now = cur;
            now *= COM(N - 1, x);
            ans = (ans + now) % MOD;
        }
        cur = cur * (M - 1) % MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 8320
#include <stdio.h>
int main(void)
{
  int n, k;
  scanf("%d %d", &n, &k);
  int d[200];
  int flag[200] = {0};
  int a[200][200] = {0};
  int count = 0;
 
  for (int i = 0; i < k; i++)
  {
    scanf("%d", &d[i]);
    for (int j = 1; j <= d[i]; j++)
    {
      scanf("%d", &a[i][j]);
    }
  }
 
  for (int i = 0; i < k; i++)
  {
    for (int j = 1; j <= d[i]; j++)
    {
      if (a[i][j] != 0)
      {
        flag[a[i][j]] = 1;
      }
    }
  }
 
  for (int i = 1; i <= n; i++)
  {
    if (flag[i] == 0)
    {
      count++;
    }
  }
 
 
  printf("%d\n", count);
  return 0;
}

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

const int N = 100001;

int main()
{
  int n;
  pair<int, int> p[N];

  cin >> n;
  for(int i=0;i < n;i++){
    cin >> p[i].second >> p[i].first;
  }
  sort(p,p+n);

  int ans = 0;
  int t = 0;
  for(int i=0;i < n;i++){
    if(t < p[i].second){
      ans++;
      t = p[i].first;
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3908
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

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

    string as, bs;
    for (int i = 0; i < b; ++i) {
        as += '0' + a;
    }
    for (int i = 0; i < a; ++i) {
        bs += '0' + b;
    }

    if (as < bs) {
        cout << as << endl;
    } else {
        cout << bs << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int n, m;
    cin >> n >> m;
    if(m == n) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
S = []
for n in range(N):
  s = input()
  if s[0] in "MARCH":
    S.append(s[0])
S_set = list(set(S))
if len(S_set) < 3:
  ans = 0
elif len(S_set) == 3:
  ans = S.count(S_set[0]) * S.count(S_set[1]) * S.count(S_set[2])
elif len(S_set) == 4:
  ans = 0
  T = [S.count(S_set[0]), S.count(S_set[1]), S.count(S_set[2]), S.count(S_set[3])]
  for i in [0, 1]:
    for j in range(i+1, len(T)-1):
      for k in range(j+1, len(T)):
        ans += T[i] * T[j] * T[k]
elif len(S_set) == 5:
  ans = 0
  T = [S.count(S_set[0]), S.count(S_set[1]), S.count(S_set[2]), S.count(S_set[3]), S.count(S_set[4])]
  for i in [0, 1, 2]:
    for j in range(i+1, len(T)-1):
      for k in range(j+1, len(T)):
        ans += T[i] * T[j] * T[k]

print(ans)

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

int main() {
    vector<int> v(5);
    while (cin >> v[0], v[0]) {
        bool g = false, c = false, p = false;
        for (int i = 1; i < 5; i++) cin >> v[i];

        for (auto i : v) {
            if (i == 1) g = true;
            if (i == 2) c = true;
            if (i == 3) p = true;
        }

        if ((g&&c&&p)||(g&&!c&&!p)||(!g&&c&&!p)||(!g&&!c&&p)) {
            for (int i = 0; i < 5; i++) cout << 3 << endl;
        } else if (g && c && !p) {
            for (auto i : v) {
                if (i == 1) cout << 1 << endl;
                else cout << 2 << endl;
            }
        } else if (g && !c && p) {
            for (auto i : v) {
                if (i == 3) cout << 1 << endl;
                else cout << 2 << endl;
            }
        } else if (!g && c && p) {
            for (auto i : v) {
                if (i == 2) cout << 1 << endl;
                else cout << 2 << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k; cin >> n >> k;
    map<int, int> s;
    pair<int, int> p[n];
    for(int i = 0; i < n; i++){
        int num; cin >> num;
        s[num]++;   
    }
    int i = 0;
    int size = s.size();

    for(map<int, int>::iterator it = s.begin(); it != s.end(); it++, i++){
        pair<int,int> w = *it;
        p[i] = make_pair(w.second, w.first);
    }
    sort(p, p+size);

    int ans = 0;
    for(int i = 0; i < size - k; i++){
        ans += p[i].first;
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 11136
import sys
from collections import deque
input = sys.stdin.readline


def main():
    h, w = map(int, input().split())
    area = [input().strip() for _ in range(h)]
    index = [[0, 1], [0, -1], [1, 0], [-1, 0]]
    maxc = 0
    for x in range(h):
        for y in range(w):
            if area[x][y] == '#':
                continue
            area_flag = [[False for j in range(w)] for i in range(h)]
            search_list = deque([[x, y, 0], ])
            area_flag[x][y] = True
            while len(search_list) > 0:
                nowx, nowy, nowc = search_list.pop()
                maxc = max(maxc, nowc)
                for ix, iy in index:
                    if 0 <= nowx+ix < h and 0 <= nowy+iy < w:
                        if area_flag[nowx+ix][nowy+iy] or area[nowx+ix][nowy+iy] == '#':
                            continue
                        else:
                            area_flag[nowx+ix][nowy+iy] = True
                            search_list.appendleft([nowx+ix, nowy+iy, nowc+1])
    print(maxc)
    

if __name__ == '__main__':
    main()


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

//Compiler version g++ 6.3.0

int main()
{
    int x, y;
    cin >> x; //count
    cin >> y; //legs
    
    int maxCranes = y / 2;
    int maxTurtles = y / 4;
    for(int j = 0; j <= maxCranes; j++)
    {
        for(int i = 0; i <= maxTurtles; i++)
        {
            if(i+j != x) continue;
            if(i*4 + j*2 != y) continue;
            cout << "Yes";
            return 0;
        }
        
    }
    cout << "No";
	return 0;
}

Measured memory_bytes: 3048
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.AGC025
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var ns = sc.Next();

            if (string.IsNullOrEmpty(ns.Substring(1)))
            {
                Console.WriteLine(ns);
            }
            else if (int.Parse(ns.Substring(1)) != 0)
            {
                var result = 0;
                foreach (var item in ns)
                {
                    result += int.Parse(item.ToString());
                }
                Console.WriteLine(result);
            }
            else
            {
                var n0 = int.Parse(ns[0].ToString());
                if (n0 == 1)
                {
                    Console.WriteLine(10);
                }
                else
                {
                    Console.WriteLine(n0);
                }
            }
        }
    }
    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>

int main ( void )
{
    int length, i;
    char data[21], tmp;

    scanf("%s", data);
    length = strlen(data);

    for ( i = 0; i < ( length / 2 ); i++ )
    {
        tmp = data[i];
        data[i] = data[length - i - 1];
        data[length - i - 1] = tmp;
    }

    printf( "%s\n", data );

    return 0;
}

Measured memory_bytes: 524
%:pragma GCC optimize("Ofast")
  %:pragma GCC optimize("inline")
#include <bits/stdc++.h>
#define rint register int
#define fo(i, n) for(rint i = 1; i <= (n); i ++)
#define out(x) cerr << #x << " = " << x << "\n"
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); ++ it)
  using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
#define P pair<int, int>
#define fi first
#define se second
const int N = 633;
vector<P> vec;
int n, d1, d2;
int col1[N][N], col2[N][N], col[N][N];
inline void dfs(int x, int y, int fff) {
  if(col[x][y] != -1) return ;
  col[x][y] = fff;
  for(auto v: vec) {
    int dx = x + v.first;
    int dy = y + v.second;
    if(dx < 0 || dx >= 2 * n || dy < 0 || dy >= 2 * n)
       continue;
    dfs(dx, dy, fff ^ 1);
  }
}               

inline void cal(int d) {
  vec.clear();
  for(int dx = -2 * n + 1; dx < 2 * n; dx ++) {
    for(int dy = -2 * n + 1; dy < 2 * n; dy ++) {
      if(dx * dx + dy * dy == d)
        vec.push_back(P(dx, dy));
    }
  }
  memset(col, -1, sizeof col);
  for(int x = 0; x < 2 * n; x ++)
    for(int y = 0; y < 2 * n; y ++)
      dfs(x, y, 0);
}
main(void) {
  read(n); read(d1); read(d2);
  cal(d1); memcpy(col1, col, sizeof col);
  cal(d2); memcpy(col2, col, sizeof col);
  for(int k1 = 0; k1 < 2; k1 ++) {
    for(int k2 = 0; k2 < 2; k2 ++) {
      int cnt = 0;
      for(int x = 0; x < 2 * n; x ++) {
        for(int y = 0; y < 2 * n; y ++)
          if(col1[x][y] == k1 && col2[x][y] == k2)
            ++ cnt;
      }
      if(cnt >= n * n) {
        int res = n * n;
        for(int x = 0; x < 2 * n; x ++) 
          for(int y = 0; y < 2 * n; y ++)
            if(col1[x][y] == k1 && col2[x][y] == k2) {
              -- res;
              cout << x << " " << y << "\n";
              if(res == 0) return 0;
            }
      }
    }
  }
}


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

int main() {
    int n;
    cin >> n;
    int ar[10][10] = {0};

    for(int i=1;i<=n;i++){
        string a;
        a = to_string(i);
        char b = a.at(0);
        char c = a.at(a.size()-1);
       ar[b-'0'][c-'0']++;
    }
    int count = 0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            count += ar[i][j]*ar[j][i];
        }
    }
    cout << count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const static int MAX = 100000;
const static int INF (1 << 30);

class Edge{
public:
    int t, w;
    Edge(){}
    Edge(int t, int w): t(t), w(w){}
};

std::vector<Edge> G[MAX];
int n, d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s){
    for(int i = 0; i < n; i++) d[i] = INF;
    std::queue<int> q;
    q.push(s);
    d[s] = 0;
    int u;

    while(!q.empty()){
        u = q.front();
        q.pop();
        for(int i = 0; i < G[u].size(); i++){
            Edge e = G[u][i];
            if( d[e.t] == INF){
                d[e.t] = d[u] + e.w;
                q.push(e.t);
            }
        }
    }
}

void solve(){
    bfs(0);
    int maxv = 0;
    int tgt = 0;
    for(int i = 0; i < n; i++){
        if(d[i] == INF) continue;
        if(maxv < d[i]){
            maxv = d[i];
            tgt = i;
        }
    }

    bfs(tgt);
    maxv = 0;
    for(int i = 0; i < n; i++){
        if(d[i] == INF) continue;
        maxv = std::max(maxv, d[i]);
    }

    std::cout << maxv << std::endl;
}

main(){
    int s, t, w;
    std::cin >> n;

    for(int i = 0; i < n-1; i++){
        std::cin >> s >> t >> w;

        G[s].push_back(Edge(t, w));
        G[t].push_back(Edge(s, w));
    }

    solve();
}


Measured memory_bytes: 9928
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  vector<long long int> l={2,1};
  for(int i=2;i< N+1;i++){
    l.push_back(l[i-2]+l[i-1]);
  }
  cout << l[N] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int a, b;

  cin>>a>>b;
  a = a+b;
  if(a>=24){
    a = a -24;
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
[n,m,l] = map(int,raw_input().split())
A = [[0 for i in range(m)] for j in range(n)]
B = [[0 for i in range(l)] for j in range(m)]
C = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    v = map(int,raw_input().split())
    for j in range(m):
        A[i][j] = v[j]
for i in range(m):
    v = map(int,raw_input().split())
    for j in range(l):
        B[i][j] = v[j]

for i in range(n):
    s = ''
    for j in range(l):
        for k in range(m):
            C[i][j] = C[i][j] + A[i][k] * B[k][j]
        if j == 0:
            s = str(C[i][j])
        else:
            s = s + ' ' + str(C[i][j])
    print s

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

using namespace std;
using ll=long long;

struct Dsu {
    int n;
    vector<int> p;
    
    Dsu(int _n) { n = _n; p.resize(n); init(); }
    inline void init() {
        for (int i = 0; i < n; i++) {
            p[i] = i;
        }
    }
    inline int find(int x) {
        return p[x] == x ? x: p[x] = find(p[x]);
    }
    inline bool join(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        p[y] = x; return true;
    }
    inline bool check(int x, int y) {
        return find(x) == find(y);
    }
};

void solve() {
    int n; ll m;
    cin >> n >> m;
    Dsu d(n);
    vector<pair<int, int>> cycle;
    int q; cin >> q;
    while (q--) {
        int x,y,c;
        cin >> x >> y >> c;
        if (c == 0) {
            d.join(x,y);
        } else {
            cycle.emplace_back(x,y);
        }
    }

    if (m == n-1) {
        cout << (cycle.empty()? "Yes" : "No");
        return;
    }
    for (auto& p: cycle) {
        int x,y;
        tie(x,y) = p;
        if (d.check(x,y)) {
            cout << "No"; return;
        }
    }
    set<int> s;
    for (int i = 0; i < n; i++) {
        s.insert(d.find(i));
    }
    ll k = s.size();
    ll lim = n + k*(k-3)/2;
    cout << (m<=lim ? "Yes" : "No");
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 6132
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# define MOD 1000000000+7
# define INF 1000000000
using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	int turn = 1;
	while (true) {
		if (turn == 1) {
			if (a.size() == 0) {
				cout << "A" << endl;
				break;
			}
			if (a[0] == 'b')turn = 2;
			if (a[0] == 'c')turn = 3;
			a.erase(a.begin());
		}
		if (turn == 2) {
			if (b.size() == 0) {
				cout << "B" << endl;
				break;
			}
			if (b[0] == 'a')turn = 1;
			if (b[0] == 'c')turn = 3;
			b.erase(b.begin());
		}
		if (turn == 3) {
			if (c.size() == 0) {
				cout << "C" << endl;
				break;
			}
			if (c[0] == 'a')turn = 1;
			if (c[0] == 'b')turn = 2;
			c.erase(c.begin());
		}
	}
}



Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Created by hikigineer on 2017/03/04.
 */
public class Main {
    static Scanner in;
    static PrintWriter out;
    static String INPUT = "";

    public static void main(String[] args) throws Exception
    {
        in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
        out = new PrintWriter(System.out);
        int A = ni();
        int B = ni();

        int result = A + B;
        if(result > 23)
            result -= 24;
        out.println(result);
        out.flush();
    }

    static int ni() {
        return Integer.parseInt(in.next());
    }
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)

int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	ll ans=1e10;
	rep(x,0,1LL<<n){
		ll temp=1;
		rep(i,0,n){
			if(bit(x,i))temp*=2;
			else temp+=k;
		}
		ans=min(ans,temp);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){

  int n;
  vector <pair<int,int> > xy;
  cin>>n;
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    xy.push_back(make_pair(x,y));
  }
  sort(xy.begin(),xy.end());
  for(int i=0;i<n;i++) cout<<xy[i].first<<" "<<xy[i].second<<endl;
  return 0;

}



Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

int main(){
    int a,b;
    cin >> a >> b;
     if(a > 9 || b > 9)cout << -1 << endl;
     else{
          cout << a*b << endl;
     }
}

Measured memory_bytes: 256
main = do
    [s,t] <- lines <$> getContents
    let acc = 0
    print $ tenki s t acc
    
tenki _ _ 3 = 0
tenki s t acc = if (s!!acc)==(t!!acc)
   then 1 + tenki s t (acc+1)
   else 0 + tenki s t (acc+1)

Measured memory_bytes: 3808
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n,d;
    cin>>n>>d;
    int x[n][d];
    int ans=0;
    rep(i,0,n-1){
        rep(j,0,d-1){
            cin>>x[i][j];
        }
    }
    int diff;
    int hoge=0;
    rep(i,0,n-1){
        rep(j,i+1,n-1){
            hoge = 0;
            rep(k,0,d-1){
                diff = abs(x[i][k]-x[j][k]);
                hoge += diff*diff;
            }
            bool flag = false;
            rep(k,0,hoge){
                if(k*k==hoge){
                    flag = true;
                    break;
                }
            }
            if(flag==true)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int grp[] = { 0,1,2,1,4,1,4,1,1,4,1,4,1 };
	int x, y;
	cin >> x >> y;
	if (grp[x] == grp[y])print("Yes");
	else print("No");






	return 0;
}

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

void solve(void){

	int x,y,z;
  cin >> x >> y >> z;
  
  cout << z << " " << x << " " << y <<endl; 
  
  return;
  
}

int main(void){
  
	solve();
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int main(){
    for(int n; cin >> n && n; ){
        int ans = INF;
        for(int z = 0; z * z * z <= n; z++)
          for(int y = 0; y * y + z * z * z <= n; y++){
              int x = n - (y * y + z * z * z);
              ans = min(ans, x + y + z);
          }
        cout << ans << endl;
    }
    return 0;
}

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

int W;
int H;
char C[114][114];
string dp[114][114];

string ans;

bool cmp(string &a, string &b) {
  if (a.size() != b.size()) return a.size() < b.size();
  for (int i=0; i<a.size(); i++) {
    if (a[i] != b[i]) return a[i] < b[i];
  }
  return false;
}

int Convert2Int(char c) {
  if ('0' <= c && c <= '9') return c - '0';
  return -1; 
}

int main() {
  while (1) {
    scanf("%d%d", &W, &H);
    if ((W|H) == 0) return 0;

    for (int i=1; i<=H; i++) {
      for (int j=1; j<=W; j++) {
        scanf(" %c", &C[i][j]);
        dp[i][j] = "";
      }
    }
  
    ans = "";
    for (int i=1; i<=H; i++) {
      for (int j=1; j<=W; j++) {
        if (Convert2Int(C[i][j]) == -1) continue; 
        if (cmp(dp[i-1][j], dp[i][j-1])) {
          dp[i][j] = dp[i][j-1] + C[i][j];
        } else {
          dp[i][j] = dp[i-1][j] + C[i][j];
        }
        if (dp[i][j] == "0") dp[i][j] = "";

        if (cmp(ans, dp[i][j])) ans = dp[i][j];
      }
    }
    printf("%s\n", ans.c_str());
  }
}

Measured memory_bytes: 3436
#include "bits/stdc++.h"
using namespace std;
bool IsCorrect[100005];
int Wrongs[100005];
char Str[5];

int main(){
    int N , m , i , p , a , b;
    scanf( "%d%d" , &N , &m );  
    fill( IsCorrect + 1 , IsCorrect + N + 1 , false );
    fill( Wrongs + 1 , Wrongs + N + 1 , 0 );

    for( i = 1 ; i <= m ; ++i ){
        scanf( "%d%s" , &p , Str );
    
        if( IsCorrect[p] == false ){
            if( Str[1] == 'A' ) ++Wrongs[p];
            else IsCorrect[p] = true;
        }
    }

    a = b = 0;

    for( i = 1 ; i <= N ; ++i ){
        if( IsCorrect[i] == true ){
            a += Wrongs[i];
            ++b;
        }
    }

    printf( "%d %d\n" , b , a );
    return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  string s0,s1;cin>>s0>>s1;
  int n=s0.length();
  for(ll i=0;i<n;i++){
    if (s0[i]!=s1[i])ans=1;
  }

if (ans==0){
  cout<<"Yes"<<endl;
  return 0;
}else{
  cout<<"No"<<endl;
  return 0;
}
  return 0;
}

Measured memory_bytes: 3624
import bisect
n = int(input())
s = input()
D = [[] for _ in range(10)]
for i in range(n):
  D[int(s[i])].append(i)
ans = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      if D[i] != []:
        l = D[i][0]
        t = bisect.bisect_right(D[j], l)
        if t < len(D[j]):
          m = D[j][t]
          q = bisect.bisect_right(D[k], m)
          if q < len(D[k]):
            ans += 1
print(ans)

Measured memory_bytes: 39920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

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

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

    int val = 2 * D + 1;
    int counter = 0;
    while(N > 0){
        N -= val;
        counter++;
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <math.h>
using namespace std;

int main() {
	string str;
	cin >> str;
	long long ans = 0, tmp;
	for (int i = 0;i < pow(2,str.size()-1);i++) {
		bitset<9> s(i);

		tmp = str[0] - '0';
		for (int j = 0;j < str.size()-1;j++) {
			if (s.test(j)) {
				ans += tmp;
				tmp = str[j + 1] - '0';
			}
			else {
				tmp *= 10;
				tmp += str[j + 1] - '0';
			}
		}
		ans += tmp;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4052
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def main():
#    h,w,a,b = map(int, input().split())
    n= int(input())
    s= list(input())
    a=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
#    a = [[0] * i for i in range(h)]
    b=[]
    for i in range(len(s)):
        temp=a.index(s[i])
        temp+=n
        if temp>=26:
            temp-=26
        s[i]=a[temp]


    c="".join(s)
    print(c)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    bool flag = false;
    deque<int> q;
    rep(i, n) {
        if (s[i] == 'W')
            flag = true;
        if (flag && s[i] == 'R')
            q.push_back(i);
    }
    int count = 0;
    rep(i, n) {
        if (q.size() == 0)
            break;
        if (s[i] == 'W') {
            q.pop_back();
            count++;
        }
        else {
            if (find(q.begin(), q.end(), i) != q.end())
                q.pop_front();
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 5024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int H, W;
    cin >> H >> W;
    int D = H * W;
    vector<string> S(H);
    REP(i, H) cin >> S[i];

    vector<vector<int>> d(D, vector<int>(D, 1e9));
    REP(i, H)REP(j, W){
        if(S[i][j] != '.')continue;
        for(int k = -1; k <= 1; k++)for(int l = -1; l <= 1; l++){
            if(k == 0 && l == 0){
                d[i*W+j][i*W+j] = 0;
            }
            else if(i+k >= 0 && i+k < H && j+l >= 0 && j+l < W && S[i+k][j+l] == '.'){
                if (k == 0 || l == 0){
                d[i*W+j][(i+k)*W+(j+l)] = 1;
                d[(i+k)*W+j+l][i*W+j] = 1;
                }

            }
        }
    }
    /*
    REP(i, D) {
        REP(j, D) cout << d[i][j] << " ";
        cout << endl;
    }
*/
    REP(l, D)REP(i, D)REP(j, D) d[i][j] = min(d[i][j], d[i][l] + d[l][j]);

    int tmp = 0;
    REP(i, D)REP(j, D){
        if (d[i][j] > tmp && d[i][j] < 1e9 ) tmp = d[i][j];
    }
    cout << tmp << endl;
/*
    REP(i, D) {
        REP(j, D) cout << d[i][j] << " ";
        cout << endl;
    }
*/

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>

#define _USE_MATH_DEFINES

using namespace std;

void CalcCircle(double rad){
    int accuracy = 6;
    double circumference, area;
    circumference = 2*rad*M_PI;
    area = rad*rad*M_PI;
    cout << fixed << setprecision(accuracy) << area << " " << circumference << endl;
}

int main(){
    // ---------------------------
    // ITP_1_4_A: A/B Problem
//    int a, b;
//    std::cin >> a >> b;
//    PrintDivision(a,b);
    // ---------------------------

    // ---------------------------
    // ITP_1_4_B: Circle
    double r;
    std::cin >> r;
    CalcCircle(r);
    // ---------------------------

    // ---------------------------
    // ITP_1_4_C:
    // ---------------------------

    // ---------------------------
    // ITP_1_4_D:
    // ---------------------------

    return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n; map<int,int>M; ll ans;
int main(){
	cin >> n;
	rep(i,n){
		int a; scanf("%d",&a); M[a]++;
	}
	vector<int>vi;
	for(map<int,int>::iterator it=M.begin();it!=M.end();it++){
		if(it->sc >= 4) ans = max(ans,1LL*(it->fi)*(it->fi));
		if(it->sc >= 2) vi.pb(it->fi);
	}
	sort(vi.begin(),vi.end(),greater<int>());
	if(vi.size() >= 2) ans = max(ans,1LL*vi[0]*vi[1]);
	cout << ans << endl;
}

Measured memory_bytes: 4992
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	ll n, l;
	re(n,l);
	vector <pair<ll,ll> > v;
	ll sum = 0;
	for(int i = 0; i < n; i++)
	{
		sum += (l + (i+1) - 1);
		//cout<< l + (i+1) -1 <<" ";
	}
	//cout<<"sum = "<<sum;
	for(int i = 0; i < n; i++)
	{
		v.pb({abs(l + (i+1) - 1),l + (i+1) - 1});
	}
	sort(v.begin(),v.end());
	cout<<sum - v[0].snd;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define double long double
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define msi map<string,int>
#define set set<int>
#define u_set unordered_set<int>
#define pb push_back
#define endl "\n"
#define ll long long int
#define vll vector<long long int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define umap unordered_map 
#define mod 1000000007
#define fori(a,n) for(int i=a;i<n;i++)
#define forj(a,n) for(int j=a;j<n;j++)
#define MAX 300303
using namespace std;
int n,m,u,v;
vi dp(100001,0);
vector<bool>done(100001,0);
int rec(vvi &graph,int i){
    if(i >= n || graph[i].size()==0)return 0;
    if(dp[i] != 0)return dp[i];
    forj(0,graph[i].size())
    {
        dp[i] = max(dp[i],1+rec(graph,graph[i][j]));
    }
    return dp[i];
}
signed main()
{
    io
    cin >> n >> m;
    vvi graph(n);
    fori(0,m){
        cin >> u >> v;
        graph[u-1].pb(v-1);
    }
    int mx = 0;
    fori(0,n)
    {
        mx = max(mx,rec(graph,i));
    }
    cout << mx << endl;

}

Measured memory_bytes: 8576
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;cin >> N;
    vector<int> A(N);
    rep(i,N)cin >> A[i];
    multiset<int> se;
    se.insert(A[0]);
    for(int i=1;i<N;i++){
        auto ite = se.lower_bound(A[i]);
        if(ite==se.begin()){
            se.insert(A[i]);
        }else{
            ite--;
            se.erase(ite);
            se.insert(A[i]);
        }
    }
    //for(auto x:se)cout << x << endl;
    cout << se.size()<< endl;
    return 0;
}

Measured memory_bytes: 5376
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;

int a;
int tetra[202];
int normal[1000002];
int odd[1000002];
vector<int>vec;
int main(){
	for (int i=1;i<=1000000;i++){
		normal[i] = 2123123;
		odd[i] = 2123123;
	}
	for (int i=1;i<=200;i++){
		tetra[i] = i * (i+1) * (i+2) / 6;
		if (tetra[i]%2)vec.push_back(tetra[i]);
	}
	for (int j=1;j<=200;j++){
		for (int i=tetra[j];i<=1000000;i++){
			normal[i] = min(normal[i-tetra[j]]+1, normal[i]);
		}
	}
	for (int j=0;j<vec.size();j++){
		for (int i=vec[j];i<=1000000;i++){
			odd[i] = min(odd[i-vec[j]]+1, odd[i]);
		}
	}
	while(scanf("%d", &a)!=EOF){
		if (a == 0) return 0;
		printf("%d %d\n", normal[a], odd[a]);
	}
	return 0;
}


Measured memory_bytes: 10540
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		char[] c = nextString().toCharArray();
		if(c[0]==c[1]&&c[1]==c[2]){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}

	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int x,y;
    if(A <= B){
      x=A;
    }if(A > B){
      x=B;
    }if(C <= D){
     y=C;
    }if(C > D){
     y=D;
    }cout<<x+y<<endl;
}

Measured memory_bytes: 3600
n=gets.to_i
n.times{
        a=gets.split.map(&:to_i)
        s="NO"
        2.downto(0){|i|
                if a[i]**2+a[i-1]**2==a[i-2]**2
                        s="YES"
                        break
                end
        }
        puts s

}

Measured memory_bytes: 8728