akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
T, A = MAP()
H = LIST()

a = abs(T - H[0]*0.006 - A)
ans = 1

for i in range(1, N):
	b = abs(T - H[i]*0.006 -A)
	if b < a:
		ans = i + 1
		a = b

print(ans)

Measured memory_bytes: 5396
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long p = sc.nextLong();
        long ans = 1;
        if (n==1){
            System.out.println(p);
        }else {
            for (long i=1;i<=1000000;i++){
                if (p%(long)Math.pow(i,n)==0)ans=i;
            }
            System.out.println(ans);
        }

    }
}


Measured memory_bytes: 35836
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll ceil(ll a, ll b) {  // a÷b以上の最小の整数
    if(b == 0) {
        return 0;
    }
    return (a+b-1)/b;
}
 
int main() {
    ll n;
    cin >> n;

    vl t(n), a(n);
    rep(i, n) {
        cin >> t[i] >> a[i];
    }

    ll x = t[0];  // 高橋くんの票数
    ll y = a[0];  // 青木くんの票数
    exrep(i, 1, n-1) {
        ll m = max(ceil(x, t[i]), ceil(y, a[i]));
        x = t[i]*m;
        y = a[i]*m;
    }

    out(x + y);
    re0;
}

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

float calcTemperature(int T, int x)
{
    float temperature = T - x * 0.006;
    return temperature;
}

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

    float mindiff = abs(A - calcTemperature(T, H[0]));

    int res = 1;

    for (int i = 0; i < N; i++)
    {
        float diff = abs(A - calcTemperature(T, H[i]));
        if (diff < mindiff)
        {
            mindiff = diff;
            res = i + 1;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD!string;
	long ans;
	foreach (i; 0..N.length)
	{
		auto a = [N[i]].to!long;
		if (i == N.length - 1)
		{
			ans += a;
			break;
		}
		auto b = [N[i+1]].to!long;
		if (a - 1 + 9 >= a + b)
		{
			ans += a - 1;
			ans += (N.length - 1 - i) * 9;
			break;
		}
		else
		{
			ans += a;
		}
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}


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

int main() {
    int x;
    cin >> x;
    if (x < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}

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

#define MAXN 57

int n ;
int a[ MAXN ] ;

vector < pair < int , int > > v ;

void solve_pos ( ) {
    int i ;
    for ( i = 1 ; i < n ; i ++ ) {
        v.push_back ( make_pair ( i , i + 1 ) ) ;
    }
}

void solve_neg ( ) {
    int i ;
    for ( i = n ; i >= 2 ; i -- ) {
        v.push_back ( make_pair ( i , i - 1 ) ) ;
    }
}

void input ( ) {
    scanf ( "%d" , &n ) ;
    int i ;
    for ( i = 1 ; i <= n ; i ++ ) {
        scanf ( "%d" , &a[ i ] ) ;
    }
}

void solve ( ) {
    int i ;
    int mn , mx ;
    int id1 , id2 ;
    mn = mx = a[ 1 ] ;
    id1 = id2 = 1 ;
    for ( i = 1 ; i <= n ; i ++ ) {
        if ( mx < a[ i ] ) { mx = a[ i ] ; id1 = i ; }
        if ( mn > a[ i ] ) { mn = a[ i ] ; id2 = i ; }
    }
    if ( mn >= 0 ) { solve_pos ( ) ; }
    else if ( mx <= 0 ) { solve_neg ( ) ; }
    else {
        if ( mx > (-mn) ) {
            for ( i = 1 ; i <= n ; i ++ ) {
                v.push_back ( make_pair ( id1 , i ) ) ;
            }
            solve_pos ( ) ;
        }
        else {
            for ( i = 1 ; i <= n ; i ++ ) {
                v.push_back ( make_pair ( id2 , i ) ) ;
            }
            solve_neg ( ) ;
        }
    }
    int sz = v.size ( ) ;
    printf ( "%d\n" , sz ) ;
    for ( i = 0 ; i < sz ; i ++ ) {
        printf ( "%d %d\n" , v[ i ].first , v[ i ].second ) ;
    }
}

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


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

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	int ans = (n + x - 1) / x * t;

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

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

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

int main() {
  int ans, ans1	= 0, ans2 = 0;
  string S; cin>>S;
  int len = S.length();
  REP(i,len) {
    if(i%2 == 0) {
      if(S[i] != '0') ans1++;
    } else {
      if(S[i] != '1') ans1++;
    }
  }
  REP(i,len) {
    if(i%2 != 0) {
      if(S[i] != '0') ans2++;
    } else {
      if(S[i] != '1') ans2++;
    }
  }
  ans =	min(ans1, ans2);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<ll,ll>pll;

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

	int p_ = 3 * a + p;
	cout << p_ / 2 << endl;

	
	return 0;
}

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

using namespace std;

#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define DFOR(a, b, c) for (register int a = b, _n = c; a > _n; --a)
#define EREP(a, b) for (register int a = first[b]; ~a; a = edge[a].nxt)
#define GREP(a, b) for (register int& a = cur[b]; ~a; a = edge[a].nxt)

int n;

int main () {
    scanf ("%d", &n);
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int len = log10(i) + 1;
        if (len & 1) ++ans;
    }

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 100007
#define INF 1000000000
using namespace std;

typedef long long ll;

int main()
{
    int n, k_len = 0;
    ll k, x = 0, tmp;
    ll a[N] = {};

    cin >> n >> k;

    vector<vector<ll>> dp(2, vector<ll>(51, -1));

    FOR(i, 0, n)
    cin >> a[i];

    dp[0][50] = 0;
    
    ll ctr;
    mFOR(i, 49, -1)
    {
        ctr = 0;
        FOR(j, 0, n)
        {
            if (a[j] & (1LL << i))
                ctr++;
        }

        dp[0][i] = dp[0][i + 1] + ((k & (1LL << i)) ? n - ctr : ctr) * (1LL << i);

        if(dp[1][i+1]>=0)
            dp[1][i] = dp[1][i + 1] + max(n - ctr, ctr) * (1LL << i);

        if (k & (1LL << i))
        {
            dp[1][i] = max(dp[1][i], dp[0][i + 1] + ctr * (1LL << i));
        }
    }

    cout << max(dp[0][0], dp[1][0]) << endl;
    return 0;
}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc177/tasks/abc177_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// int lcm(int c, int d) { return c / gcd(c, d) * d; }

const int SZ = 1e6;

// constexprな素数列挙(エラトステネスの篩)
// https://259-momone.hatenablog.com/entry/2018/05/06/015026
template <int N> struct Prime {
    bool b[N + 1]; // trueなら素数
    constexpr Prime() : b() {
        fill_n(b, N + 1, true);
        b[0] = b[1] = false;
        for (int i = 2; i <= N; ++i) {
            if (b[i]) {
                for (int j = i * i; j <= N; j += i) {
                    b[j] = false;
                }
            }
        }
    }
};
Prime<SZ> prime;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N), D(SZ + 1);
    for (auto &x : A) {
        cin >> x;
        // 同じ数が重複するケースを考慮
        D[x]++;
    }
    bool pc = true;

    REP(i, SZ) {
        // 素数の場合
        if (prime.b[i]) {
            int cnt = 0;
            for (int now = i; now <= SZ; now += i) {
                cnt += D[now];
            }
            // 共通の素数を含むのでgcd(ALL) >= i
            if (cnt >= 2) {
                pc = false;
                break;
            }
        }
    }
    if (pc) {
        cout << "pairwise coprime" << endl;
    } else {
        int g = A[0];
        for (auto &x : A) {
            g = gcd(g, x);
        }
        if (g == 1)
            cout << "setwise coprime" << endl;
        else
            cout << "not coprime" << endl;
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 19836
L, R = map(int, input().split(" "))

ans = 2019
for i in range(L, min(R, L + 2019 * 10)):
    for j in range(i + 1, min(R+1, L + 2019 * 10)):
        ans = min(ans, (i * j) % 2019)
        if ans == 0:
            break

print(ans)

Measured memory_bytes: 39664
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n;
  ll ar[n];
  rep(i,0,n)
  cin>>ar[i];
  rep(i,0,n){
    if(ar[i]%2==0)
    {
      if(ar[i]%3==0 || ar[i]%5==0) continue;
      else {cout<<"DENIED";return;}
    }
  }
  cout<<"APPROVED";
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main() {

    int A, B, C, D;
    scanf("%d %d %d %d", &A, &B, &C, &D);

    int L = A + B;
    int R = C + D;
    if (L == R) printf("Balanced\n");
    else if (L < R) printf("Right\n");
    else printf("Left\n");

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
long long int GCD(long long int x,long long int y){return y==0? x:GCD(y,x%y);}
int main(void){
	long long n,m;
	char s[100000],t[100000];
	scanf("%lld %lld",&n,&m);
	scanf("%s %s",s,t);
	if(s[0]!=t[0]){
		printf("-1");
		return 0;
	}
	long long num,i;
	long long g=GCD(n,m);
	num = n*(m/g);
	if(g==1){printf("%lld",num);return 0;}
	long long a=num/n,b=num/m,c=GCD(a,b);
	for(i=1;i<num;i+=c){
		if(i%a==0 && i%b==0){
			if(s[i/a]!=t[i/b]){
				printf("-1");
				return 0;
			}
		}
	}
	
	
	
	printf("%lld",num);
	
	return 0;
}

Measured memory_bytes: 384
# https://atcoder.jp/contests/arc061/tasks/arc061_a

from itertools import product

S = input()
l = len(S)

res = 0
for a in product(*[[0,1],]*(l-1)):
    c = 0
    st = S[0]
    for i, b in enumerate(a, start=1):
        if b == c:
            st += S[i]
        else:
            res += int(st)
            st = S[i]
        c = b
    res += int(st)

print(res)

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

int main() {
	string s;
	ll K;
	cin >> s >> K;
	int n = s.size();
	int dp[105][4][2] = {0};
	dp[0][0][0] = 1;	//空集合は一致している
	rep(i,n) rep(j,4) rep(k,2) {	// i:桁数、j:非ゼロの数、k:0だとnと一致、1だとn以下 
		int nd = s[i] - '0'; //nd:今の桁のnの数
		rep(d, 10){	// d:桁の数（0～9）
			int ni = i + 1, nj = j, nk = k;
			if(d != 0) nj++;	
			if(nj > K) continue;	//非ゼロの数がオーバー
			if(k == 0) {
				if(d > nd) continue;
				if(d < nd) nk = 1;
				// d = ndの場合、nkは0のまま
			}	//kが1の場合、残りの桁は何でもnk = 1
			dp[ni][nj][nk] += dp[i][j][k];
		}
	}
	int ans = dp[n][K][0] + dp[n][K][1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define ll long long int
#define fo(i,n) for(i=0;i<(n);i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
//==============================================================================================================

ll bin_pow(ll a, ll n)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)res = res * a;
        a = a * a;
        n = n >> 1;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    ll t, d; cin >> t >> d;
    ll count = 0;
    while (t--)
    {
        ll a, b; cin >> a >> b;
        if ((sqrt(bin_pow(a, 2) + bin_pow(b, 2))) <= d)count++;
    }
    cout << count << "\n";
}

Measured memory_bytes: 3568
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(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 bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N, L = li_input()
    S = [input() for _ in range(N)]

    S.sort()
    print("".join(S))


main()


Measured memory_bytes: 4764
#define _USE_MATH_DEFINES
#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 long ull;
int mod = 1000000007;

int main(){
    string s;
    ull k;
    cin>>s>>k;
    int ss=s.size();
    for(int j=0;j<ss;j++){
        if(s[j]!='1'){
            cout<<s[j]<<endl;
            break;
        }
        if(j==k-1){
            cout<<s[j]<<endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int days(int m){
	if(m==1)
		return 0;
	else if(m==2)
		return days(1)+31;
	else if(m==3)
		return 29+days(2);
	else if(m==4)
		return 31+days(3);
	else if(m==5)
		return 30+days(4);
	else if(m==6)
		return 31+days(5);
	else if(m==7)
		return 30+days(6);
	else if(m==8)
		return 31+days(7);
	else if(m==9)
		return 31+days(8);
	else if(m==10)
		return 30+days(9);
	else if(m==11)
		return 31+days(10);
	else if(m==12)
	    return 30+days(11);
}
int main(){
	int m, d;
	while(cin>>m>>d){
		if(m==0)
			break;
		d+=days(m);
		if(d%7==1)
			cout<<"Thursday";
		else if(d%7==2)
			cout<<"Friday";
		else if(d%7==3)
			cout<<"Saturday";
		else if(d%7==4)
			cout<<"Sunday";
		else if(d%7==5)
			cout<<"Monday";
		else if(d%7==6)
			cout<<"Tuesday";
		else
			cout<<"Wednesday";
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3036
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>n>>m>>k;
    ll int ara[n+1]={0},arr[m+1]={0};
     for(i=1;i<=n;i++){
        cin>>ara[i];
        sum+=ara[i];
     }
     for(i=1;i<=m;i++){
        cin>>arr[i];
     }
     for(i=1;i<=n;i++){
        ara[i]+=ara[i-1];
     }
     for(j=1;j<=m;j++){
        arr[j]+=arr[j-1];
     }
     sum=0;j=m;p=0;
     for(i=0;i<=n;i++){
        if(ara[i]>k){
            break;
        }
        while(arr[j]>k-ara[i])j--;
        sum=max(sum,i+j);
     }

     cout<<sum<<endl;

     return EXIT_SUCCESS;
}


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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long double db;

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

template<typename T> void print(const T& a, ostream& out){	
	for(auto i: a) out << i << ' ';
	out << endl;
}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	int n, x, t;
	cin >> n >> x >> t;
	cout << ((n + x - 1) / x) * t << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL;

using namespace std;

int A, B, C;

int main() {
	cin >> A >> B >> C;
	vector<int> v;
	v.pb(A);
	v.pb(B);
	v.pb(C);
	sort(all(v));
	int op;
	int ret = 0;
	op = (v[2] - v[0]) / 2;
	ret += op;
	v[0] += op * 2;

	op = (v[2] - v[1]) / 2;
	ret += op;
	v[1] += op * 2;

	sort(all(v));
	if (v[0] == v[1]){
		if (v[0] != v[2])
			ret++;
	}
	else if (v[1] == v[2])
		ret += 2;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


n, k = map(int, input().split())

SUSHI = []
for _ in range(n):
    t, d = map(int, input().split())
    SUSHI.append((d, t))
SUSHI.sort(reverse = True)

NEW = {i:True for i in range(1, n + 1)}
x, y = 0, 0
A, B = [], []

for d, t in SUSHI[:k]:
    if NEW[t]:
        x += d; y += 1
        NEW[t] = False
    else:
        x += d
        A.append(d)

for d, t in SUSHI[k:]:
    if NEW[t]:
        B.append(d)
        NEW[t] = False
B.sort()

answer = x + y**2
while A and B:
    a, b = A.pop(), B.pop()
    x -= a; x += b; y += 1
    if x + y**2 > answer:
        answer = x + y**2

print(answer)


Measured memory_bytes: 28736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException{


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String word = br.readLine();
        word = word + word;
        String key = br.readLine();
        boolean result = false;

        if(word.indexOf(key) != -1){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
    }
}

Measured memory_bytes: 24412
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
int main(){
  long long N;
  cin >> N;

  if(N % 2 == 1){
    cout << 0 << endl;
  } else {
    long long two_no = 0;
    long long two_pow = 2;
    long long pow_count = 1;
    while(two_pow <= N){
      two_no += N / two_pow;
      pow_count ++;
      two_pow *= 2;
    }
    long long five_no = 0;
    long long five_pow = 5;
    pow_count = 1;
    while(five_pow <= N){
      long long tmp = N / five_pow;
      if(tmp % 2 == 1){
        five_no += (tmp - 1) / 2;
      } else {
        five_no += tmp / 2;
      }
      pow_count ++;
      five_pow *= 5;
    }
    cout << min(two_no, five_no) << endl;

  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			long a = sc.nextLong();

			long b = a / 500;
			long c = (a % 500) / 5;

			// 出力(整数)
			System.out.println(b * 1000 + c * 5);
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int a,b,c,d;
    while(cin>>a>>b>>c>>d){
    	cout<<(a-c)*(b-d)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
//-------wh1ter0se--------------//
#include<bits/stdc++.h>
#define int long long
using namespace std;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) { return (a.second > b.second);}
int32_t main()
{
    string s;
  	cin>>s;
  	int count=0,maxcount=0,j;
  	for(int i=0;i<s.length();i++)
    {
      if(s[i]=='R')
      {
        count=1;
       	for(j=i+1;j<s.length();j++)
        {
          if(s[j]=='R')
            count++;
          else
              break;
        }
        maxcount=max(maxcount,count);
        i=j;
      }

    }
    cout<<maxcount<<endl;

}


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

typedef long long ll;

const ll MOD = 1e9 + 7;
ll N, M;

ll fact(ll n) { return n == 0 ? 1 : n * fact(n - 1) % MOD; }
ll solve() {
  if (abs(M - N) >= 2) return 0;
  ll res = M == N ? 2 : 1;
  (res *= fact(N)) %= MOD;
  (res *= fact(M)) %= MOD;
  return res;
}
int main() {
  cin >> N >> M;
  cout << solve() << endl;
  return 0;
}


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

using namespace std;

#define MAX 10000

int par[MAX], rank[MAX];

void initUnionFind(int N){
  for(int i = 0 ; i < N ; i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }
  return par[x] = find(par[x]);
}

void unite(int x, int y){
  x = find(x);
  y = find(y);

  if(x == y) return;

  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rank[x] == rank[y]){
      ++rank[x];
    }
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

int main(){
  int n, q, a, b ,c;

  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> n >> q; initUnionFind(n);
  for(int i = 0 ; i < q ; i++){
    cin >> a >> b >> c;
    if(a == 0){
      unite(b, c);
    }else{
      cout << (same(b,c) ? 1 : 0) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1272
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut ans = 0;
    let mut q = std::collections::VecDeque::new();
    q.push_back(3usize);
    q.push_back(5);
    q.push_back(7);

    while let Some(v) = q.pop_front() {
        if v > n {
            break;
        }

        let mut c3 = false;
        let mut c5 = false;
        let mut c7 = false;
        let mut t = v;
        while t > 0 {
            match t % 10 {
                3 => c3 = true,
                5 => c5 = true,
                7 => c7 = true,
                _ => continue,
            }
            t /= 10;
        }
        if c3 && c5 && c7 {
            ans += 1;
        }
        q.push_back(v * 10 + 3);
        q.push_back(v * 10 + 5);
        q.push_back(v * 10 + 7);
    }

    println!("{}", ans);
}


Measured memory_bytes: 2344
#include<iostream>

using namespace std;

int main(){
	int h, w, i, j, cnt;
	char s[50][50];
	cin >> h >> w;
	for (i = 0; i < h; i++){
		for (j = 0; j < w; j++){
			cin >> s[i][j];
		}
	}
	for (i = 0; i < h; i++){
		for (j = 0; j < w; j++){
			if (s[i][j] == '#'){
				if (s[i - 1][j] == '#' || s[i][j - 1] == '#' || s[i][j + 1] == '#' || s[i + 1][j] == '#'){
					
				}
				else{
					cnt++;
				}
			}
		}
	}
	if (cnt == 0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

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

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Search(int n, int[] A)
        {
            int l = 0;
            int r = A.Length - 1;
            if (n <= A[l]) { return A.Length; }
            if (n > A[r]) { return 0; }
            while (r - l >= 2)
            {
                int m = (l + r) / 2;
                if (n <= A[m]) { r = m; } else { l = m; }
            }
            return A.Length - l - 1;
        }

        static long Solve(int N, int M, int[] A, int[] B)
        {
            const int MOD = 1000000007;
            Array.Sort(A);
            Array.Sort(B);
            var rows = new HashSet<int>();
            var cols = new HashSet<int>();
            foreach (int a in A)
            {
                if (rows.Contains(a)) { return 0; }
                rows.Add(a);
            }
            foreach (int b in B)
            {
                if (cols.Contains(b)) { return 0; }
                cols.Add(b);
            }
            long ans = 1;
            for (int i = N * M; i > 0; --i)
            {
                bool x = rows.Contains(i);
                bool y = cols.Contains(i);
                int h = Search(i, A);
                int w = Search(i, B);
                if (!x && !y)
                {
                    ans *= h * w - (N * M - i);
                    ans %= MOD;
                }
                else if (x && y)
                {
                    // do nothing
                }
                else if (x)
                {
                    ans *= w;
                    ans %= MOD;
                }
                else if (y)
                {
                    ans *= h;
                    ans %= MOD;
                }
            }
            return ans;
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int N = V[0], M = V[1];
            int[] A = ReadInts();
            int[] B = ReadInts();
            Console.WriteLine(Solve(N, M, A, B));
        }
    }
}


Measured memory_bytes: 13536
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe
import           Data.Ord
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.IO                 as AIO



getvuil :: IO (VU.Vector Int)
getvuil = VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
readi :: BSC8.ByteString -> Int
readi = fst . fromJust . BSC8.readInt
readil :: BSC8.ByteString -> [Int]
readil = map readi . BSC8.words
geti :: IO Int
geti = readi <$> BSC8.getLine
getil :: IO [Int]
getil = readil <$> BSC8.getLine

getNis :: Int -> IO [(Int, BSC8.ByteString)]
getNis 0 = return []
getisl n = do
    [aFst, aSnd] <- BSC8.words <$> BSC8.getLine
    next         <- (getisl (n - 1))
    return ((readi aFst, aSnd) : next)

il2ss :: [Int] -> String
il2ss = unwords . map show

il2sn :: [Int] -> String
il2sn = unlines . map show

main :: IO ()
main = do
    [aA, aB] <- getil
    let ret = foldl
            (\acc x ->
                if (acc == -1)
                    && ((div (x * 8) 100) == aA)
                    && ((div (x * 10) 100) == aB)
                then
                    x
                else
                    acc
            )
            (-1)
            [1 .. 2000]
    print ret




Measured memory_bytes: 508
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(str[0]);
            int b = Convert.ToInt32(str[1]);

            int[] ret = new int[3];
            ret[0] = a + b;
            ret[1] = a - b;
            ret[2] = a * b;

            int maxv = int.MinValue;
            for (int i = 0; i < ret.Length; i++)
            {
                if (ret[i]>maxv)
                {
                    maxv = ret[i];
                }
            }
            
            System.Console.WriteLine(maxv);
        }
    }
}



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

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

      long long q,n,k,i,count=0,j=0,l,r,ans=0,p,m,x;
      cin>>n>>k;
      if(n%k==0)
      cout<<n/k;
      else cout<<n/k+1;
      
    
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
sc=[list(map(int,input().split())) for _ in range(M)]

answer=[]

if N==1:
    for j in range(10):
        a=0
        for i in range(M):
            if int(str(j)[sc[i][0]-1])==sc[i][1]:
                a+=1
            else:
                break
        if a==M:
            answer.append(j)
else:
    for j in range(10**(N-1),10**N):
        a=0
        for i in range(M):
            if int(str(j)[sc[i][0]-1])==sc[i][1]:
                a+=1
            else:
                break
        if a==M:
            answer.append(j)
if len(answer)>=1:
    print(min(answer))
    #print(answer)
else:
    print(-1)


Measured memory_bytes: 3188
#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 mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;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())
double dp[305][305][305];
int n,a[3];
double rec(int a,int b,int c){
	if(dp[a][b][c] >= -1e16) return dp[a][b][c];
	if(a+b+c == 0) return 0.0;
	double sum = 0;
	if(a) sum += (double)(a)/(double)(a+b+c)*rec(a-1,b,c); // pick a 1 pile
	if(b) sum += (double)(b)/(double)(a+b+c)*rec(a+1,b-1,c); // pick a 2 pile
	if(c) sum += (double)(c)/(double)(a+b+c)*rec(a,b+1,c-1);
	sum += 1.0*(double)(n)/(double)(a+b+c);
	return dp[a][b][c] = sum;
}
int main(){
	cin>>n;
	for(int i=0;i<305;i++) for(int j=0;j<305;j++) for(int k=0;k<305;k++){
		dp[i][j][k]=-1e18;
	}
	for(int i=0;i<305;i++) for(int j=0;j<305;j++) for(int k=0;k<305;k++){
		if(i+j+k > n) continue;
		dp[i][j][k] = rec(i,j,k);
	}
	rep(i,n){
		int x; cin>>x; a[x-1]++;
	}
	printf("%.12f\n",dp[a[0]][a[1]][a[2]]);
}


Measured memory_bytes: 221952
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

string s;

int solve() {
  int ans1{}, ans2{};
  for (size_t i = 0; i < s.size(); ++i) {
    if (i % 2 == 0) {
      if (s[i] == '1') ++ans1;
    } else {
      if (s[i] == '0') ++ans1;
    }
  }
  for (size_t i = 0; i < s.size(); ++i) {
    if (i % 2 == 0) {
      if (s[i] == '0') ++ans2;
    } else {
      if (s[i] == '1') ++ans2;
    }
  }
  return min(ans1, ans2);
}

int main() {
  cin >> s;
  cout << solve() << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main(){
    string s;
    cin>>s;
    s[3]='8';
    cout<<s<<endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>

using namespace std;

#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 501;

int a[maxn][maxn], used[maxn][maxn];

int n;

int xx[4] = {0, 0, -1, 1};
int yy[4] = {-1, 1, 0, 0};

void upd(int x, int y) {
    queue<pair<int, int>> q;
    q.push({x, y});
    a[x][y]--;
    while (!q.empty()) {
        auto v = q.front();
        q.pop();
        for (int i = 0; i < 4; i++) {
            int nx = v.x + xx[i], ny = v.y + yy[i];
            if (0 <= nx && nx < n && 0 <= ny && ny < n && (a[nx][ny] - 2 == a[v.x][v.y] || (used[nx][ny] == 1 && a[nx][ny] - 1 == a[v.x][v.y]))) {
                q.push({nx, ny});
                a[nx][ny]--;
            }
        }
    }
}

void show() {
    for (int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            cout << a[i][j] << " ";
        }
        cout << "\n";
    }
    cout << "\n\n";
}

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

    cin >> n;
    vector<int> p(n * n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> p[i * n + j];
            a[i][j] = min(min(i + 1, j + 1), min(n - i, n - j));
        }
    }
    int ans = 0;
    for (int i = 0; i < n * n; i++) {
        p[i]--;
        int ii = p[i] / n, jj = p[i] % n;
        ans += a[ii][jj] -  1;
        upd(ii, jj);
        used[ii][jj] = 1;
//        show();
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 6176
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> mp;
int inf =  1e9;

vector<int> daikus( vector<vector<int> >&g , int s ){
    vector<int> res( g.size() , inf );
    vector<bool> used( g.size() , false );
    res[s] = 0;
    used[s] = true;
    queue<mp> q;
    q.push( mp( 0, s ) );
    while( !q.empty() ){
	mp now = q.front();
	q.pop();
	int nn = now.second;
	int cost = now.first;
	for(int i=0;i<g[nn].size();i++){
	    int next = g[nn][i];
	    //if( res[ next ] <= cost + 1 ) continue;
	    if( used[next] )continue;
	    res[next] = cost + 1;
	    used[next] = true;
	    q.push( mp( cost + 1 ,next ) );
	}
    }
    return res;
}


int main(){
    int n,m,s,t;
    cin>>n>>m>>s>>t;
    s--,t--;
    vector< vector<int> > g(n);
    for(int i=0;i<m;i++){
	int u,v;
	cin>>u>>v;
	u--,v--;
	g[u].push_back( v );
	g[v].push_back( u );
    }
    vector<int> sd = daikus( g ,s );
    vector<int> td = daikus( g, t );
    vector<ll> cnts( n+1 , 0 );
    vector<ll> cntt( n+1 , 0 );
    int pass = sd[t];
    for(int i=0;i<n;i++) {
	if( sd[i] != inf )cnts[ sd[i] ]++ ;
	if( td[i] != inf )cntt[ td[i] ]++;
    }
    //cout<<"OK"<<endl;
    ll res = 0;
    for(int i=0;i<pass-1;i++){
	res += cnts[i]*cntt[pass-i-2];
    }
    cout<<res<<endl;

    return 0;
}



Measured memory_bytes: 11700
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
double EPS=1e-10;
double add(double a, double b)
{
	if(abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
	return a+b;
}
double x[5],y[5];
bool input()
{
	bool suc=false;
	for(int i=0;i<4;i++) 
	{
		if(!i && scanf("%lf,%lf",&x[i],&y[i])!=EOF) suc=true;
		else if(i && scanf(",%lf,%lf",&x[i],&y[i])!=EOF) suc=true;
	}
	if(suc) return true;
	else return false;
}
int main()
{
	while(input())
	{
		bool failed=false; x[4]=x[0],y[4]=y[0];
		double vx[5],vy[5];
		for(int i=0;i<4;i++) vx[i]=x[i+1]-x[i],vy[i]=y[i+1]-y[i];
		vx[4]=vx[0],vy[4]=vy[0];
		bool plus=true;
		if(add(vx[0]*vy[1],-vy[0]*vx[1])<0) plus=false;
		for(int i=0;i<4;i++)
		{
			if(plus && add(vx[i]*vy[i+1],-vy[i]*vx[i+1])<0 ) failed=true;
			else if(!plus && add(vx[i]*vy[i+1],-vy[i]*vx[i+1])>0 ) failed=true;
		}
		if(failed) cout << "NO" << '\n' ;
		else cout << "YES" << '\n' ;
	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=203,INF=1<<20;

pair<int,int> dp[MAX][MAX];
int cnt[MAX][MAX];
bool seen[MAX][MAX];
string S;
int N;

pair<int,int> ch(pair<int,int> &a,pair<int,int> b){
    a.first=max(a.first,b.first);
    a.second=min(a.second,b.second);
    return a;
}

pair<int,int> solve(int l,int r){
    if(seen[l][r]) return dp[l][r];
    
    seen[l][r]=1;
    
    if(l==r-1){
        if('0'<=S[l]&&S[l]<='9'){
            return dp[l][r]={S[l]-'0',S[l]-'0'};
        }else{
            return dp[l][r]={-INF,INF};
        }
    }
    
    pair<int,int> ret={-INF,INF};
    
    if(S[l]=='('){
        ch(ret,solve(l+1,r));
    }
    
    if(S[r-1]==')'){
        ch(ret,solve(l,r-1));
    }
    
    for(int i=l+1;i<r-1;i++){
        if(S[i]=='+'){
            bool ok=true;
            if(S[i-1]==')'){
                if(cnt[l][i]<=1) ok=false;
            }
            if(S[i+1]=='('){
                if(cnt[i+1][r]<=1) ok=false;
            }
            pair<int,int> a=solve(l,i),b=solve(i+1,r);
            if(a.first<a.second||b.first<b.second) ok=false;
            
            if(ok){
                ch(ret,{a.first+b.first,a.second+b.second});
            }
        }
        if(S[i]=='-'){
            bool ok=true;
            if(S[i-1]==')'){
                if(cnt[l][i]<=1) ok=false;
            }
            if(S[i+1]=='('){
                if(cnt[i+1][r]<=1) ok=false;
            }
            pair<int,int> a=solve(l,i),b=solve(i+1,r);
            if(a.first<a.second||b.first<b.second) ok=false;
            
            if(ok){
                ch(ret,{a.first-b.second,a.second-b.first});
            }
        }
    }
    
    return dp[l][r]=ret;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>S;
    N=S.size();
    
    for(int i=0;i<N;i++){
        for(int j=i+1;j<=N;j++){
            int s=0;
            for(int k=i;k<j;k++){
                if('0'<=S[k]&&S[k]<='9') s++;
            }
            cnt[i][j]=s;
        }
    }
    
    cout<<solve(0,N).first<<endl;
}




Measured memory_bytes: 3700
import java.util.*;

public class Main {

    public static String doPlan(int[] t, int[] x, int[] y) {
        for (int i = 0; i < t.length - 1; i++) {
            int t1 = t[i];
            int t2 = t[i+1];
            int x1 = x[i];
            int x2 = x[i+1];
            int y1 = y[i];
            int y2 = y[i+1];
            if (((t2 - t1) >= Math.abs(x2 - x1) + Math.abs(y2 - y1))
                && ((t2 - t1) % 2 == (Math.abs(x2 - x1) + Math.abs(y2 - y1)) % 2)) {

            } else {
                return "No";
            }
         }
         return "Yes";
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] t = new int[N + 1];
        int[] x = new int[N + 1];
        int[] y = new int[N + 1];
        t[0] = 0;
        x[0] = 0;
        y[0] = 0;
        for (int i = 1; i <= N; i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        System.out.println(doPlan(t, x, y));
    }

}


Measured memory_bytes: 93680
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vll A(X), B(Y), C(Z);
  for(int i = 0; i < X; i++){
    cin >> A.at(i);
  }
  for(int i = 0; i < Y; i++){
    cin >> B.at(i);
  }
  for(int i = 0; i < Z; i++){
    cin >> C.at(i);
  }
  sort(ALL(A), greater<ll>()); sort(ALL(B), greater<ll>()); sort(ALL(C), greater<ll>());
  ll sum = A.at(0) + B.at(0) + C.at(0);
  priority_queue<ll, vector<ll>, greater<ll>> bc;
  bool flag = false;
  for(int i = 0; i < Y; i++){
    for(int j = 0; j < Z; j++){
      ll num = B.at(0) - B.at(i) + C.at(0) - C.at(j);
      bc.push(num);
    }
  }
  priority_queue<ll, vector<ll>, greater<ll>> que;
  for(int i = 0; i < 3000; i++){
    if(bc.empty()) break;
    ll x = bc.top(); bc.pop();
    for(int j = 0; j < X; j++){
      ll num = A.at(0) - A.at(j) + x;
      que.push(num);
    }
  }
  for(int i = 0; i < K; i++){
    ll num = que.top(); que.pop();
    cout << sum - num << endl;
  }
}

Measured memory_bytes: 42876
import sys
input=sys.stdin.readline

n=int(input())
a,b,c,d=-10**9,10**9,-10**9,10**9
for _ in range(n):
	x,y=map(int,input().split())
	a=max(a,x+y)
	b=min(b,x+y)
	c=max(c,x-y)
	d=min(d,x-y)
print(max(a-b,c-d))

Measured memory_bytes: 9232