akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<map>

using namespace std;
#define cerr cerr << "[DBG] "
#define DBG(x) cerr << #x << ": " << x << endl
// http://genkisugimoto.com/jp/blog/procon/2015/04/15/print-debug-technique-in-cpp.html
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { s << v[i]; if (i < v.size() - 1) s << "\t"; } return s; }

typedef long long ll;

#define divisor 2019

main(){
    string s;
	cin >> s;
    vector<int> a;
    int n=s.size();
    for(int i=0;i<n;i++){
        a.push_back(s[i]-'0');
    }
    int curr[divisor];
    int prev[divisor];
    for(int i=0;i<divisor;i++){
        curr[i]=prev[i]=0;
    }

    int result = 0;
    for(int i=0;i<n;i++){
        curr[a[i]]++;
        if(i!=0){
            for(int ii=0;ii<divisor;ii++){
                if(prev[ii]==0) continue;
                int rem=(ii*10+a[i])%divisor;
                curr[rem]+=prev[ii];
            }
        }
        result+=curr[0];
        for(int ii=0;ii<divisor;ii++){
            prev[ii]=curr[ii];
            curr[ii]=0;
        }
    }

	cout << result << endl;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(j, m) for (int j = 0; j < (int)(m); j++)
#define rep2(i, l, n) for (int i = l; i < (int)(n); i++)


int main() {
    int X;
    cin >> X;
    int ans = 0;
    rep2(i,2,32) {
        int a = i*i;
        if (a <= X) {
            while(true) {
                if (a > ans) {
                    ans = a;
                }
                a *= i;
                if (a > X) {
                    break;
                }
            }
        }
    }
    if (X < 4) {
        ans = 1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3620
#include <iostream>


using namespace std;

int N;


int main()
{

	int ans = 0;

	cin >> N;

	int n = N;
	int r = 1;

	while (1) {

		if (r > N) {
			break;
		}
		else if (r * 10 > N) {
			ans += N - r + 1;
			break;
		}
		else{

			ans += r * 9;
			r *= 100;
		}
	}


	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>
#include <unordered_map>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    int n;
    cin >> n;
    vector<ll> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    unordered_map<ll, ll> mp;
    unordered_map<ll, ll> mp2;
    for(int i = 1; i <= n; i++){
        ll tmp = a[i]+i;
        if(mp.count(tmp) == 0){
            mp[tmp] = 1;
        } else {
            mp[tmp] += 1;
        }
        tmp = i - a[i];
        if(mp2.count(tmp) == 0){
            mp2[tmp] = 1;
        } else {
            mp2[tmp] += 1;
        }
    }

    ll ans = 0;
    for(auto i = mp.begin(); i != mp.end(); i++){
        if(mp2.count((*i).first) != 0){
            ans += (*i).second*mp2[(*i).first];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 20112
#include <iostream>

// int inf = 1 << 28;
int inf = 100000000;

int dijk(int n,int s, int **g) {
	int sum = 0;
	bool *used = new bool[n];
	int *d = new int[n];

	for(int i = 0; i < n; i++){
		d[i] = inf;
		used[i]=false;
	}
	d[s] = 0;

	while(true) {
		int u = -1;
		for(int v = 0; v < n; v++)
			if(!used[v] && (u == -1 || d[v] < d[u]))
				u = v;

		if(u == -1) break;
		used[u] = true;

		for(int v = 0; v < n; v++)
			if(d[v] > d[u] + g[u][v])
				d[v] = d[u] + g[u][v];
	}

	for(int i = 0; i < n; i++) {
		sum += d[i];
	}

	return sum;
}

int main() {
	do {
		int **g; // adjacency matrix, ?
		int *d;
		int *a, *b, *c;
		int edge = 0, min = 0, max = 0;
		int tmp = 0;

		std::cin >> edge;
		if(!edge) break;

		a = new int[edge];
		b = new int[edge];
		c = new int[edge];

		for(int i = 0;i < edge;i++) {
			std::cin >> a[i];
			std::cin >> b[i];
			std::cin >> c[i];
		}

		for(int i = 0; i < edge; i++) {
			if(max < a[i])
				max = a[i];
		}
		for(int i = 0; i < edge; i++) {
			if(max < b[i])
				max = b[i];
		}
		max++;

		g = new int*[max];
		d = new int[max];

		for(int i = 0; i < max; i++) {
			g[i] = new int[max];
		}

		for(int i = 0; i < max; i++)
			for(int j = 0; j < max; j++)
				g[i][j] = inf;

		for(int i = 0; i < edge; i++)
			g[b[i]][a[i]] = g[a[i]][b[i]] = c[i];

		for(int i = 0; i < max; i++)
			d[i] = dijk(max, i, g);

		min = d[0];
		for(int i = 1; i < max; i++) {
			if(min > d[i]) {
				min = d[i];
				tmp = i;
			}
		}

		std::cout << tmp << " " << min << std::endl;
		for(int i = 0; i < max; i++)
			delete[] g[i];
		delete[] g;
		delete[] a;
		delete[] b;
		delete[] c;
		delete[] d;

	}while(true);
	return 0;
}

Measured memory_bytes: 0
N, M = map(int, input().split())
a, b, ans = [], [], []
max0 = 10**10

for i in range(N):
    a += [list(map(int, input().split()))]

for i in range(M):
    b += [list(map(int, input().split()))]

for i in a:
    for j, k in enumerate(b):
        val = abs(i[0]-k[0])+abs(i[1]-k[1])
        if val < max0:
            pre = j
            max0 = val
    ans.append(pre+1)
    max0 = 10**10
[print(x) for x in ans]



Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
int main() {
  
  int N;
  cin>>N;
  
  string S;
  cin>>S;
  
  int check=0;
  
  int ans=0;
  
  
  string X,Y;
  
   for(int i=0;i<N-1;i++) {
    X=S.substr(0,i+1);
    Y=S.substr(i+1);
    sort(X.begin(),X.end());
    for(int j=0;j<X.size();j++) {
      if(j==0||X[j]!=X[j-1]) {
        for(int k=0;k<Y.size();k++) {
          if(X[j]==Y[k]) {
            check++;
            break;
          }
        }
      }
    }
    
    if(check>ans){
      ans=check;
    }
    check=0;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>

using namespace std;

int main()
{
	int b1, b2, b3;
	cin >> b1 >> b2 >> b3;

	if ((b1 == 1 && b2 == 0 && b3 == 0) || (b1 == 0 && b2 == 1 && b3 == 0) || (b1 == 0 && b2 == 0 && b3 == 0))
		cout << "Close" << endl;
	else
		cout << "Open" << endl;
	return 0;
}

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

int main()
{
  char *a = (char *)malloc(4);
  char *b = (char *)malloc(4);

  scanf("%s", a);
  scanf("%s", b);
  char c = b[0];
  b[0] = b[2];
  b[2] = c;
  if(strcmp(a, b)){
    printf("NO\n");
  }else{
    printf("YES\n");
  }

  free(a);
  free(b);
  
  return 0;
}

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

int main(void)
{
	int a;
	int b;
	int c;
	scanf("%d%d%d",&a,&b,&c);
	if(c-b<1){
		printf("delicious\n");
	}else if(c-b-a<1){
		printf("safe\n");	
	}else{
		printf("dangerous");	
	}
	return 0;
	
}

Measured memory_bytes: 128
// Aizu Vol-0 0043: Puzzle
// 2017.8.11

#include <stdio.h>
#include <string.h>
#include <ctype.h>

char *gets();
char buf[30], *p;
int tbl[15], *e = tbl+10;

int check(int n, int two)
{
	int *t, k;

	if (n == 14) return 1;
	for (t = tbl + 1; t < e; t++) {
		if (!*t) continue;
		if (*t == 1 && !*(t + 1) && !*(t + 2)) return 0;
		if (*(t + 1) > 0 && *(t + 2) > 0) {
			(*t)--, (*(t + 1))--, (*(t + 2))--;
			k = check(n + 3, two);
			(*t)++, (*(t + 1))++, (*(t + 2))++;
			if (k) return 1;
		}
		if (two && *t >= 2) {
			(*t) -= 2;
			k = check(n + 2, 0);
			(*t) += 2;
			if (k) return 1;
		}
		if (*t >= 3) {
			(*t) -= 3;
			k = check(n + 3, two);
			(*t) += 3;
			if (k) return 1;
		}
	}
	return 0;
}

int main()
{
	int i, f, *t;

	while (gets(p = buf) != NULL) {
		while (isspace(*p)) p++;
		memset(tbl, 0, sizeof(tbl));
		for (i = 0; i < 13; i++) tbl[*p++ - '0']++;
		for (t = tbl+1; t < e; )
			if (*t++ > 4) goto NG;
		for (f = 0, t = tbl+1, i = 1; t < e; i++, t++) {
			if (*t== 4) continue;
			(*t)++;
			if (check(0, 1)) {
				if (!f) f = 1; else putchar(' ');
				putchar(i + '0');
			}
			(*t)--;
		}
		if (!f) {
NG:			putchar('0');
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 524
#include<stdio.h>
#include<algorithm>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <functional>
#include <time.h>
using namespace std;
clock_t fi, endtime;

const int INF = 100*6001;
const int r_c = 0;
const int r_t = 1;
const int MAX_V = 100;
const int MAX_E = 6000;

int main()
{
	while (1) {
		int n, m, a, b, c, t;
		int k, p, q, r;

		int wft[MAX_V][MAX_V];
		int wfc[MAX_V][MAX_V];

		scanf("%d %d", &n, &m);
		if (n == 0 && m == 0) break;
		for (int i = 0; i < m; ++i) {
			for (int j = 0; j < m; ++j) {
				wfc[i][j] = INF; wft[i][j] = INF;
			}
		}
		for (int i = 0; i < n; ++i) {
			scanf("%d %d %d %d", &a, &b, &c, &t);
			wft[a - 1][b - 1] = t;  wft[b - 1][a - 1] = t;
			wfc[a - 1][b - 1] = c;  wfc[b - 1][a - 1] = c;
		}
		for (int l = 0; l < m; ++l) {
			for (int i = 0; i < m; ++i) {
				for (int j = 0; j < m; ++j) {
					if (wft[i][j] > wft[i][l] + wft[l][j]) { wft[i][j] = wft[i][l] + wft[l][j]; }
					if (wfc[i][j] > wfc[i][l] + wfc[l][j]) { wfc[i][j] = wfc[i][l] + wfc[l][j]; }
				}
			}
		}
		scanf("%d", &k);
		int ans = 0;
		for (int i = 0; i < k; ++i) {
			scanf("%d %d %d", &p, &q, &r);
			if (r == 0) { ans = wfc[p - 1][q - 1]; }
			else { ans = wft[p - 1][q - 1]; }
			printf("%d\n", ans);
		}
	}
}

Measured memory_bytes: 3180
def main():
    N = int(input())
    A = [int(_) for _ in input().split()]
    dp = [[0] * 2 for _ in range(N-1)]
    dp[0][0] = A[0] + A[1]
    dp[0][1] = -(A[0] + A[1])
    for i in range(1, N-1):
        dp[i][0] = max(dp[i-1][0]+A[i+1], dp[i-1][1]+A[i+1])
        dp[i][1] = max(dp[i-1][0]-2*A[i]-A[i+1], dp[i-1][1]+2*A[i]-A[i+1])
    print(max(dp[N-2][0], dp[N-2][1]))
    return

if __name__ == '__main__':
    main()


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

a = list(map(int,input().split()))
l = []

if not 1 in a:
    print(-1)
    exit()

s = 0
cnt = 0
for i in a:
    if i == s + 1:
        l.append(i)
        s = i
    else:    
        cnt += 1

print(cnt)  

Measured memory_bytes: 26268
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    cin>>a;
    if(a/10==9||a%10==9) Yes;
    else No;
    return 0;
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  
  vector<ll> p(a), q(b), r(c);
  priority_queue<ll, vector<ll>, greater<ll>> pq;
  for (int i = 0; i < a; i++) cin >> p.at(i);
  for (int i = 0; i < b; i++) cin >> q.at(i);
  for (int i = 0; i < c; i++) cin >> r.at(i);
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  sort(r.rbegin(), r.rend());
  
  ll ans = 0;
  for (int i = 0; i < x; i++) {
    ans += p.at(i);
    pq.push(p.at(i));
  }
  for (int i = 0; i < y; i++) {
    ans += q.at(i);
    pq.push(q.at(i));
  }
  
  for (int i = 0; i < min(x + y, c); i++) {
    ll keep = 0;
    keep += r.at(i);
    keep -= pq.top();
    pq.pop();
    ans = max(ans, ans + keep);
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 4852
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] S = sc.nextLine().split(" ");
        long N = Long.parseLong(S[0]);
        long A = Long.parseLong(S[1]);
        long B = Long.parseLong(S[2]);
        sc.close();

        long time = N / (A + B);
        long times = N % (A + B);

        if (times > A) {
            times = A;
        }

        long blueCount = time * A + times;
        System.out.println(blueCount);

    }

}


Measured memory_bytes: 25300
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    S = rl().rstrip()
    T = rl().rstrip()
    
    ans = 0
    for si, ti in zip(S, T):
        if si != ti:
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 68224
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

int main(){
  nvec(int,a,5);
  for (int i = 0; i < 5; i++) {
    if(a[i]==0)cout<<i+1;
  }

}


Measured memory_bytes: 3616
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

struct player {
    int pos = 0;
    int prev_day = 0;
};

pair<int, int> mp(int x, int y)
{
    return { min(x, y), max(x, y) };
}

void update_for(const vector<vector<int> >& A, const vector<player>& players,
                int x, queue<pair<int, int>>& q, set<pair<int, int> >& used)
{
    if(1U * players[x].pos >= A[x].size())
        return;

    int y = A[x][players[x].pos];
    auto p = mp(x, y);

    if(A[y][players[y].pos] == x && !used.count(p)) {
        q.push(p);
        used.insert(p);
    }
}

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

    vector<vector<int> > A(n, vector<int>(n - 1));

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n - 1; ++j) {
            cin >> A[i][j];
            --A[i][j];
        }
    }

    vector<player> players(n);

    queue<pair<int, int> > q;
    set<pair<int, int> > used;

    for(int i = 0; i < n; ++i)
        update_for(A, players, i, q, used);

    while(!q.empty()) {
        auto p = q.front();
        q.pop();

        int x = p.first;
        int y = p.second;
        int day = max(players[x].prev_day, players[y].prev_day) + 1;

        players[x].prev_day = day;
        players[y].prev_day = day;

        ++players[x].pos;
        ++players[y].pos;

        update_for(A, players, x, q, used);
        update_for(A, players, y, q, used);
    }

    // cerr << "---" << endl;
    // for(int i = 0; i < n; ++i) {
    //    cerr << players[i].prev_day << " " << players[i].pos << endl;
    // }

    int mx = 0;
    for(int i = 0; i < n; ++i) {
        if(players[i].pos != n - 1) {
            cout << -1 << endl;
            return 0;
        }

        mx = max(players[i].prev_day, mx);
    }

    cout << mx << endl;

    return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  int W, N;
  int v[1001], w[1001];
  for(int t = 1; scanf("%lld", &W), W; t++) {
    scanf("%lld", &N);
    rep(i, N) scanf("%lld,%lld", &v[i], &w[i]);

    int dp[1001] = {0};
    for(int i = 0; i < N; i++) {
      for(int j = W; j >= w[i]; j--) {
	dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
      }
    }

    int aw = 0;
    while(dp[aw] != dp[W]) aw++;

    printf("Case %d:\n%d\n%d\n", t, dp[aw], aw);
  }

  return 0;
}

Measured memory_bytes: 3148
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val s = read()
    val t = read()

    var count = 0
    for(i in 0 until 3) {
        if(s[i] == t[i]) {
            count++
        }
    }
    println(count)

    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }


// Extensions
fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 33696
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

#debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    S = II()

    import math
    s = math.sqrt(S)
    if int(s) == s:
        print(0, 0, 0, int(s), int(s), 0)
        return

    sd = math.floor(s)
    su = math.ceil(s)
    x1 = su
    y1 = 0
    x2 = 1
    y2 = su
    Stmp = x1 * y2
    diff = Stmp - S
    y1 = diff

    dprint(S, s, sd, su)

    print(0, 0, int(x1), int(y1), int(x2), int(y2))

solve()

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
  int a,b[100],d,i;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d ",&b[i]);
  }
  d=a-1;
  for(i=d;i>=0;i--){
    if (i>0)printf("%d ",b[i]);
    else printf("%d",b[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2040
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#define mp make_pair
#define pb push_back
using namespace std;

template<class T>inline void read(T &x) {
  x = 0;
  T tmp = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') tmp = -1, c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + c - '0', c = getchar();
  x *= tmp;
}

const int N = 110;
int n, a[N];

int main(void) {
  read(n);
  for (int i = 1; i <= n; ++i)
    read(a[i]);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int j = 1;
    while (i + j <= n && a[i + j - 1] == a[i + j]) ++j;
    ans += (j >> 1);
    i += j - 1;
  }
  printf("%d\n", ans);

  return 0;
}


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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

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

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}

void chmax(ll &a,const ll &b){
    if(a<b) a=b;
}
void chmin(ll &a,const ll &b){
    if(a>b) a=b;
}


int main()
{

    ll a,b,c,d,e;
    cin >>a>>b>>c>>d>>e;

    cout << 15-a-b-c-d-e << endl;




    return 0;


}

Measured memory_bytes: 3592
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000;

using ll = long long;
using namespace std;

int main(){
    int k, s,all_sum, count=0;
    cin >> k >> s;
    rep(i, k+1){
        rep(j, k+1){
                all_sum = i+j-s;
                if(all_sum<=0 && all_sum>=-k) count++;
            
        }
    }
    cout << count << endl;
}


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

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

	vector<int> vecE(n);
	vector<int> vecW(n);

	vecW[0] = 0;
	vecW[n - 1] = 0;

	for (int i = 1; i < n; i++) {
		vecE[n - i - 1] = vecE[n - i];
		vecW[i] = vecW[i - 1];
		if (s[i - 1] == 'W') vecW[i]++;
		if (s[n - i] == 'E') vecE[n - i - 1]++;
	}

	int ans = n;
	for (int i = 0; i < n; i++) {
		ans = min(vecW[i] + vecE[i], ans);
	}
	cout << ans << endl;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	REP(i,N){
		int c=in<char>();
		if(c=='Y'){
			out("Four");
			return 0;
		}
	}
	out("Three");
	
	return 0;
}


Measured memory_bytes: 256
def make_combination(fro, to, value, weight, W):
    """ビット演算が重いのでグレイコードを使った"""
    combination = []
    w = 0
    v = 0
    combination.append([w, v])
    for i in range(1, 1 << (to - fro)):
        code = i ^ (i >> 1)
        bitpos = 0
        while not (1 << bitpos & i):
            bitpos += 1
        if (1 << bitpos & code):
            w += weight[bitpos + fro]
            v += value[bitpos + fro]
        else:
            w -= weight[bitpos + fro]
            v -= value[bitpos + fro]
        combination.append([w, v])

    # 必要のない組み合わせを弾く
    combination.sort()
    for i in range(len(combination) - 1):
        if combination[i][1] > combination[i + 1][1]:
            combination[i + 1][1] = combination[i][1]

    return combination


def cal_ans(from_0_to_half_combination, from_half_to_N_combination, W):
    ans = 0

    """ 尺取り法 """
    left = 0
    right = len(from_half_to_N_combination) - 1
    for left in range(len(from_0_to_half_combination)):
        now_weight = from_0_to_half_combination[left][0]
        now_value = from_0_to_half_combination[left][1]
        while now_weight + from_half_to_N_combination[right][0] > W and right != 0:
            right -= 1
        if now_weight + from_half_to_N_combination[right][0] <= W:
            ans = max(ans, now_value + from_half_to_N_combination[right][1])

    """ 二分探索 """
    # for now in range(len(from_0_to_half_combination)):
    #     now_weight = from_0_to_half_combination[now][0]
    #     now_value = from_0_to_half_combination[now][1]
    #     count = 0
    #     left = 0
    #     right = len(from_0_to_half_combination) - 1
    #     while count < 45:
    #         mid = (left + right) // 2
    #         if now_weight + from_half_to_N_combination[mid][0] > W:
    #             right = mid - 1
    #         else:
    #             ans = max(ans, now_value + from_half_to_N_combination[mid][1])
    #             left = mid + 1
    #         count += 1

    return ans


def main():
    N, W = map(int, input().split())
    half = N // 2
    value = []
    weight = []
    for i in range(N):
        v, w = map(int, input().split())
        value.append(v)
        weight.append(w)

    # 半分全列挙の組み合わせを前半と後半で作る
    from_0_to_half_combination = make_combination(0, half, value, weight, W)
    from_half_to_N_combination = make_combination(half, N, value, weight, W)

    # 尺取り法か二分探索で計算
    ans = cal_ans(from_0_to_half_combination, from_half_to_N_combination, W)
    print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 341980
var arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

if( arr[0] < arr[1] ) {
  var temp = arr[0]
  arr[0] = arr[1]
  arr[1] = temp
}

switch (arr[0] == arr[1]) {
case true:
	print( arr[0] * 2 )
default:
  	print( arr[0] + arr[0] - 1 )
}

Measured memory_bytes: 4208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();

		// 1 3 5 7 8 10 12
		// 4 6 9 11
		// 2
		if (checkGroup(x) == checkGroup(y)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	private static int checkGroup(int n) {
		int result = 0;
		switch (n) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			result = 1;
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			result = 2;
			break;
		case 2:
			result = 3;
			break;
		}
		return result;
	}

}


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

int main(int argc, char* argv[])
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if (0 < x + r && x + r <= W && 0 < y + r && y + r <= H) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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


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

    int n,H,W;
    cin>>n>>W>>H;
    int w,x,y;
    int a[W+2]={},b[H+2]={};
    for(int i=0;i<n;i++){
        cin>>x>>y>>w;
        a[max(0,min(W,x-w+1))]++;
        a[min(W+1,x+w+1)]--;
        b[max(0,min(H,y-w+1))]++;
        b[min(H+1,y+w+1)]--;
    }
    bool pos=true;
    for(int i=1;i<=W;i++){
        a[i]+=a[i-1];
    }
    for(int i=1;i<=H;i++){
        b[i]+=b[i-1];
    }
    for(int i=1;i<=W;i++){
        if(a[i]==0) pos=false;
    }
    if(pos){
        cout<<"Yes"<<endl;
        return 0;
    }
    pos=true;
    for(int i=1;i<=H;i++){
        if(b[i]==0){
            pos=false;
        }
    }
    if(pos){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;


}


Measured memory_bytes: 3988
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long ans = 0;
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		long K = long.Parse(str[1]);
		long[]A = new long[N];
		string[] str2 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str2[i]);
		}
		long mod = 1000000007;
		long a = 0;
		for(var i=N-1;i>=0;i--){
			for(var j=i-1;j>=0;j--){
				if(A[j]>A[i]){
					a++;
				}
			}
		}
		long a2 = 0;
		for(var i=N-1;i>=0;i--){
			for(var j=N-1;j>=0;j--){
				if(A[j]>A[i]){
					a2++;
				}
			}
		}
		long b = (K-1)*K/2 % mod;
		ans = a * K % mod + a2 * b % mod;
		Console.WriteLine(ans%mod);
	}
}

Measured memory_bytes: 13144
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;

const int MAX_N = 100000;

vector<int> adj[MAX_N + 1];

bool visited[MAX_N + 1];

void dfs(int u) {
   visited[u] = true;
   for (int v : adj[u]) {
      if (!visited[v]) dfs(v);
   }
}

int main() {

   int n, m;
   scanf("%d %d", &n, &m);
   for (int i = 0; i < m; i++) {
      int a, b;
      scanf("%d %d", &a, &b);
      adj[a].push_back(b);
      adj[b].push_back(a);
   }
   int ans = 0;
   for (int i = 1; i <= n; i++) {
      if (visited[i]) continue;
      ans++;
      dfs(i);
   }
   printf("%d\n", ans - 1);

   return 0;
}



Measured memory_bytes: 9300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n;
    cin >> n;
    vector<ll> x(n), y(n);
    ll a = INF, b = 0, c = 2 * INF, d = 0;
    rep(i, n) {
        cin >> x[i] >> y[i];
        ll k = x[i] + y[i];
        ll l = (INF - x[i]) + y[i];
        chmin(a, k);
        chmax(b, k);
        chmin(c, l);
        chmax(d, l);
    }
    cout << max(b - a, d - c) << endl;
}

Measured memory_bytes: 6428
N = int(input())
A = [0 for i in range(N)]
B = [0 for i in range(N)]
C = [0 for i in range(N)]
st = input().split()
for i in range(N):
    A[i] = int(st[i])
st = input().split()
for i in range(N):
    B[i] = int(st[i])
st = input().split()
for i in range(N):
    C[i] = int(st[i])
A.sort();C.sort()
M = 0
for i in range(N):
    low = 0
    high = N - 1
    t = (low + high) // 2
    if A[N-1] < B[i]:
        t = N-1
    elif A[0] >= B[i]:
        t = -1
    else:
        while (low <= high):
            if A[t] < B[i] <= A[t+1]:
                break
            elif B[i] <= A[t]:
                high = t
            elif A[t+1] < B[i]:
                low = t+1
            t = (low + high) // 2
    low = 0
    high = N - 1
    s = (low + high) // 2
    if C[N-1] <= B[i]:
        s = N-1
    elif B[i] < C[0]:
        s = -1
    else:
        while (low <= high):
            if C[s] <= B[i] < C[s+1]:
                break
            elif B[i] < C[s]:
                high = s
            elif C[s+1] <= B[i]:
                low = s + 1
            s = (low + high) // 2
    M += (t+1)*(N-s-1)
print(M)

Measured memory_bytes: 103012
#include <iostream>
int main() {
  int n, a, b, p1, p2;
  std::cin >> n >> a >> b;

  p1 = a * n;
  p2 = b;

  if (p1 <= p2) std::cout << p1 << std::endl;
  else std::cout << p2 << std::endl;
}


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

typedef long long ll;
typedef pair<int, int> ii;

int k, cnt;
ll res;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> k;
    queue<ll> que;
    for (ll i : {1,2,3,4,5,6,7,8,9}) {
      que.push(i);
    }

    while (cnt++ < k) {
      res = que.front();
      que.pop();
      int lb = res % 10;
      if (lb > 0) {
        que.push(res * 10 + lb - 1);
      }
      que.push(res * 10 + lb);
      if (lb < 9) {
        que.push(res * 10 + lb + 1);
      }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;} 

template<typename T>
struct SegmentTree {
private:
    int n; //最下層のノード数。v.size以上の最小の2ベキ。
    vector<T> node;

public:
    SegmentTree(vector<T> v) { //O(n)
        n = 1LL << ((int)log2(v.size())+1);
        node.resize(n-1);
        move(v.begin(), v.end(), back_inserter(node));
        node.resize(2*n-1, INF);
        for(int i=n-2; i>=0; --i) node[i] = min(node[2*i+1], node[2*i+2]);
    }
    void update(int x, int val) { //O(logn)
        x += n - 1; //最下段ノード
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }
    T getmin(int a, int b, int k=0, int l=0, int r=-1) { //O(logn)
        if(r < 0) r = n;
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return node[k];

        return min(getmin(a, b, 2*k+1, l, (l+r)/2), getmin(a, b, 2*k+2, (l+r)/2, r));
    }
};

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

// 平方分割によるRMQ　O(√N)
int n, q; cin >> n >> q;
VI a(n, (1LL<<31)-1);
SegmentTree<i64> ST(a);

rep(_, 0, q){
    int c, x, y; cin >> c >> x >>  y;
    if (c) cout << ST.getmin(x, y+1) <<"\n";
    else ST.update(x, y);
}
return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．




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

#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define all(x) x.begin(),x.end()
#define F(i, n) for (i = 0; i < (1LL*n); i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }

mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);
}
vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
// ll q;
ll i, j;
ll a, b, c;
ll mod = 1000000007;
ll cas=0;

void solve()
{
    string s;
    cin>>s;
    ans=0;
    if(s[0]=='R'){
        if(s[1]=='R'){
            if(s[2]=='R')prn(3);
            else prn(2);   
        }
        else prn(1);
    }
    else if(s[1]=='R'){
        if(s[2]=='R')prn(2);
        else prn(1);
    }
    else if(s[2]=='R')prn(1);
    else prn(0);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    ll t = 1;
    // cin >> t;
    cas=1;
    // stress();
    while (t--){
        solve();
        cas++;
    }
    return 0;
}

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

int main(){
  long long sum = 0;
  int input, max = -1000000, min = 1000000, count = 0, limit;

  cin >> limit;

  while ( count < limit ){
    cin >> input;
    min = min > input ? input : min;
    max = max < input ? input : max;
    sum = sum + input;
    count++;
  }

  cout << min << " " << max << " " << sum << "\n";

  return 0;

}

Measured memory_bytes: 1168
#include <stdio.h>

#include <stdlib.h>

#include <math.h>
 
void def(int num, double x1, double y1, double x2, double y2);
 
int main()
{
  int num;

  double array1[2], array2[2];
 
  array1[0] = 0;

  array1[1] = 0;

  array2[0] = 100;

  array2[1] = 0;
 
  scanf("%d", &num);
 
  printf("%f %f\n", array1[0], array1[1]);
 
  def(num, array1[0], array1[1], array2[0], array2[1]);
 
  return 0;
}
 
  void def(int num, double x1, double y1, double x2, double y2)
{
  double arrs[2], arrt[2], arru[2];
  double arrr3 = sqrt(3.0);
 
  if (num == 0){

    printf("%f %f\n", x2, y2);

    return;
  }
 
  else {
    arrs[0] = x1 + (x2 - x1) / 3.0;
    arrs[1] = y1 + (y2 - y1) / 3.0;
    arrt[0] = x1 + 2*(x2 - x1) / 3.0; 
    arrt[1] = y1 + 2*(y2 - y1) / 3.0;
    arru[0] = arrs[0] + (-arrs[0] + arrr3 * arrs[1] + arrt[0] - arrr3 * arrt[1]) / 2.0; 
    arru[1] = arrs[1] + (-arrr3 * arrs[0] - arrs[1] + arrr3 * arrt[0] + arrt[1]) / 2.0; 
    def(num - 1, x1, y1, arrs[0], arrs[1]); 
    def(num - 1, arrs[0], arrs[1], arru[0], arru[1]); 
    def(num - 1, arru[0], arru[1], arrt[0], arrt[1]); 
   def(num - 1, arrt[0], arrt[1], x2, y2);
  }
}

Measured memory_bytes: 636
use strict;
use warnings;

my $s = <STDIN>;
my ($n1, $n2, $n3, $n4) = split //, $s;
my $is_true = 0;

if (($n2 == $n3) and (($n1 == $n2) or ($n3 == $n4))) {
    $is_true = 1;
}

if ($is_true) {
    print "Yes\n";
} else {
    print "No\n";
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
char c[405][405];
bool seen[400][400];
int h, w;
long long dfs(const int &i, const int &j, long long &ca, long long &cb) {
	//連結成分内の黒の数をca，白の数をcb
	if (seen[i][j]) return 0;  // 1回見られていたら見なくてよい
	seen[i][j] = 1;
	if (c[i][j] == '#')  //今見ているマスが黒か白か
		ca++;
	else
		cb++;
	rep(k, 4) {  // 4回で下右上左の順に隣接マスを見ていく
		int nx = i + dx[k], ny = j + dy[k];
		if (nx < 0 or h <= nx or ny < 0 or w <= ny) continue;  //マスからはみ出していないか
		if (c[i][j] != c[nx][ny]) dfs(nx, ny, ca, cb);         //隣が違う色のマスなら探索
	}
	return ca * cb;
}
int main() {
	scanf("%d%d", &h, &w);
	rep(i, h) scanf("%s", c[i]);  // cが与えられた二次元配列
	long long ans = 0;                  //答え
	rep(i, h) rep(j, w) {
		long long ca = 0, cb = 0;
		ans += dfs(i, j, ca, cb);  //連結成分内の黒の数と白の数の積を答えに足していく
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 15488
#include <cstdio>
// #include <cmath>
#include <cstdlib>

int main() {
    int N, K;
    scanf(" %d", &N);
    scanf(" %d", &K);

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int x;
        scanf(" %d", &x);
        ans += (x < abs(K-x)) ? x*2 : abs(K-x)*2;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;

int pole[3000][2];
int n;
int bin_search(int x, int y){
    int h=0;
    int t=n;
    int temp;
    while(h<=t){
        temp = (t+h)/2;
        if(x == pole[temp][0] && y == pole[temp][1]){
            return true;
        }
        else if(x > pole[temp][0] ||
               (x == pole[temp][0] && y > pole[temp][1])) t = temp-1;
        else h = temp+1;
    }
    return false;
}
int push(int x, int y, int limit){
    int a=0;
    while(a < limit && (x<pole[a][0] ||(x==pole[a][0] && y<pole[a][1]))){
        a++;
    }
    for(int i=limit;i>a;i--){
        swap(pole[i][0], pole[i-1][0]);
        swap(pole[i][1], pole[i-1][1]);
    }
    pole[a][0] = x; pole[a][1] = y;
}
int main(){
    int temp[2];
    int dx, dy;
    int tx[2], ty[2];
    int m;
    cin >> n;
    while(n){
        m = 0;
        for(int i=0;i<n;i++){
            cin >> temp[0] >> temp[1];
            push(temp[0], temp[1], i);
        }
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                dx = abs(pole[i][0] - pole[j][0]);
                dy = abs(pole[i][1] - pole[j][1]);
                if(bin_search(pole[i][0]+dy, pole[i][1]+dx) &&
                   bin_search(pole[j][0]+dy, pole[j][1]+dx)){
                    m = max(dx*dx + dy*dy, m);
                }
            }
        }
        cout << m << endl;
        cin >> n;
    }
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    cout << (X - A) % B << endl;
}


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

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  k++;
  int A[k], B[k] , C[k];
  int ans=0;
  A[0]=a;
  B[0]=b;
  C[0]=c;
  for(int i=1;i<k;i++){
    A[i] = 2*A[i-1];
    B[i] = 2*B[i-1];
    C[i] = 2*C[i-1];
  }
  rep(i,k){
    rep(j,k){
      rep(l,k){
        if(A[i]<B[j]&&B[j]<C[l]){
          if((i+j+l)<k){
            ans=1;
            break;
          }
        }
      }
      if(ans)break;
    }
    if(ans)break;
  }

  vector<int> v(3);


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


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

using namespace std;

const int maxn=1e6+9;

long long gcd(long long a,long long b)
{
    return b==0?a:gcd(b,a%b);
}

char s[maxn],t[maxn];

int main()
{
    long long n,m,l,y1,y2,y3,g;
    scanf("%lld %lld",&n,&m);
    scanf("%s",s);
    scanf("%s",t);
    g=gcd(n,m);
    l=m*n/g;
    y1=l/n;
    y2=l/m;
    int i1=0,i2=0;
    for(;;)
    {
        if(s[i1]!=t[i2])
        {
            l=-1;
            break;
        }
        i1+=y2;
        i2+=y1;
        //cout<<i1<<" "<<i2<<endl;
        if(i1>=n || i2>=m)
            break;
    }
    printf("%lld\n",l);
    return 0;
}


Measured memory_bytes: 384
a1, a2, a3 = input(), input(), input()
a1 = [int(i) for i in a1.split()]
a2 = [int(i) for i in a2.split()]
a3 = [int(i) for i in a3.split()]
A = [a1, a2, a3]
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))
for i in range(len(b)):
    for j in range(len(A)):
        for k in range(len(A[0])):
            if b[i] == A[j][k]:
                A[j][k] = 0
ans = 0
for i in range(3):
    if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
        ans = 1
    if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
        ans = 1
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    ans = 1
if A[2][0] == 0 and A[1][1] == 0 and A[0][2] == 0:
    ans = 1
if ans == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{ 
 
 
    static long mod=1000000007;
    static int dx[]={1,-1,0,0};
    static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1};
    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 
    //HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
 
    public  static void main(String[] args)   throws Exception, IOException{
     
        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
     
        // int n=sc.nextInt();
        // long n=sc.nextLong();
        // char c[][] = new char[h][w];
        // long a[] = new long [n];
        // for (int i=0; i<n; i++) {a[i]=sc.nextInct();}

        out.println(48-sc.nextInt());
        out.flush();
    }

    static void db(Object... os){
     
        System.err.println(Arrays.deepToString(os));
     
    }
     
    static boolean validpos(int x,int y,int r, int c){
        
        return x<r && 0<=x && y<c && 0<=y;
        
    }
     
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}
 
class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return -x + p.x;//des
    } 
}
 
class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 20820