akhauriyash/Code-Regression huggingface dataset:
module Circle =
  struct
    type t = { x: float; y:float; r:float }
    let eps = 1e-10
    let set x y r = {x = x; y = y; r = r}
    let dist c1 c2 = sqrt ((c1.x -. c2.x) *. (c1.x -. c2.x) +. (c1.y -. c2.y) *. (c1.y -. c2.y))
    let intersection c1 c2 = 
      let d = dist c1 c2 in
      if d -. c1.r -. c2.r > eps then 0
      else if c1.r -. c2.r -. d > eps then 2
      else if c2.r -. c1.r -. d > eps then -2
      else 1
  end

let _ = 
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  for i = 1 to n do
    let c1,c2 = Scanf.scanf "%f %f %f %f %f %f\n" (fun xa ya ra xb yb rb -> (Circle.set xa ya ra, Circle.set xb yb rb)) in
    Printf.printf "%d\n" @@ Circle.intersection c1 c2
  done

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

int main() {
  int N,K,x;
  cin >> N >> K;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> x;
    sum += (2*min(x,abs(K-x)));
  }
  cout << sum;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define all(a) a.begin(),a.end()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)

typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

const int inf = 1e9;

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

int R;
int W[2], H[2];
int X[2], Y[2];
int A[2][502][502];

bool used[502][502];

vpii data[2];

void bfs(int num)
{
	typedef pair<int, pii> Data;
	memset(used, false, sizeof(used));

	priority_queue<Data> q;

	q.push(Data(-1, pii(Y[num], X[num])));
	used[Y[num]][X[num]] = true;

	if (num == 0) {
		data[num].PB(pii(1, 0));
	} else {
		data[num].PB(pii(0, 0));
		data[num].PB(pii(0, 1));
	}

	int ma = 1;
	int cnt = 0;
	int hoge = 0;

	while (q.size()) {
		Data p = q.top(); q.pop();

		int cur = -p.fst;

		if (ma < cur) {
			if (num == 0) {
				data[num].back().scd = cnt;
			} else {
				data[num].back().fst = cnt;
			}

			ma = cur;

			if (num == 0) {
				data[num].PB(pii(ma, 0));
			} else {
				data[num].PB(pii(0, ma));
			}
		}

		cnt++;

		rep(i, 4) {
			int ny = p.scd.fst + dy[i], nx = p.scd.scd + dx[i];

			if (ny < 0 || ny >= H[num] || nx < 0 || nx >= W[num] || used[ny][nx]) continue;
			used[ny][nx] = true;

			q.push(Data(-A[num][ny][nx], pii(ny, nx)));
		}
	}

	if (num == 0) {
		data[num].back().scd = cnt;
	} else {
		data[num].back().fst = cnt;
	}
}

signed main()
{
	omajinai;

	while (cin >> R, R) {
		data[0].clear();
		data[1].clear();

		rep(i, 2) {
			cin >> W[i] >> H[i] >> X[i] >> Y[i];

			--X[i], --Y[i];

			rep(j, H[i]) rep(k, W[i]) {
				cin >> A[i][j][k];
			}
		}

		bfs(0);
		bfs(1);

		int mi = inf;

		data[1].PB(pii(inf, inf));

		rep(i, data[0].size()) {
			pii a = data[0][i];

			chmin(mi, a.fst + lower_bound(all(data[1]), pii(R - a.scd, -inf))->scd);
		}

		cout << mi << endl;
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<char> a(n+1);
  
  for(int i = 0; i < n; i++){
  	cin >> a.at(i);
  }
  
  bool g = true;
  for(int i = 0; i < n+1; i++){
  	if(a.at(i) == 'Y'){
    	break;
    }
  	if(i == n){
    	g = false;
    }
  }
  if(g){
  	cout << "Four" << endl;
  }
  else{
  	cout<< "Three" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  long long n,m; cin>>n>>m;
  if(n>m) cout<<min(abs(n-n/m*m),abs(n-n/m*m-m));
  else cout<<min(n,m-n);
  return 0;
}


Measured memory_bytes: 3596
program main
      implicit none
      integer(4) :: x, y, a, b, c
      integer(8), allocatable :: p(:), q(:), r(:)
      integer(8), allocatable :: arr(:)
      integer(8) :: i, red, grn, key, total

      read(*,*) x, y, a, b, c
      allocate( p(a) )
      allocate( q(b) )
      allocate( r(c) )
      read(*,*) p
      read(*,*) q 
      read(*,*) r

      call quicksort1( p, 1, a )
      call quicksort1( q, 1, b )
      allocate( arr( x+y+c ) )
      arr(1:x) = p(a-x+1:a)
      arr(x+1:x+y) = q(b-y+1:b)
      arr(x+y+1:x+y+c) = r

      call quicksort1( arr, 1, x+y+c )
      total = sum( arr(c+1:x+y+c) ) 
      print *, total

      contains

      recursive subroutine quicksort1(a, first, last)
        implicit none
        integer(8),intent(inout)::a(*)
        integer,intent(in)::first,last
        !
        ! Original
        ! https://gist.github.com/t-nissie/479f0f16966925fa29ea
        !
        integer(8)::x,t
        integer::i,j
      
        x = a((first+last)/2)
        i = first
        j = last
        do
           do while (a(i) < x)
              i=i+1
           end do
           do while (x < a(j))
              j=j-1
           end do
           if (i >= j) exit
           t = a(i)
           a(i) = a(j)
           a(j) = t
           i=i+1
           j=j-1
        end do
        if (first < i-1) call quicksort1(a, first, i-1)
        if (j+1 < last)  call quicksort1(a, j+1, last)
      
        return
      end subroutine quicksort1
end program main 


Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define ll long long int
#define INF INT_MAX
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
	chutiyaap;
	ll a,b;
	cin>>a>>b;
	if(a>=13)cout<<b;
	else if(a>=6&&a<13)cout<<b/2;
	else cout<<0;
}


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

int main(){
    int mxi[3],mxj[3];
    int c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
        mxi[i]=min(min(c[i][0],c[i][1]),c[i][2]);
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            c[i][j]-=mxi[i];
        }
    }
    for(int i=0;i<3;i++){
        mxj[i]=min(min(c[0][i],c[1][i]),c[2][i]);
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            c[j][i]-=mxj[i];
            if(c[j][i]!=0){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	int n;
	
	while (cin >> n, n)
	{
		char grid[n][n];
		int W[n][n];
		int maxWidth = 0;
		
		REP(n) cin >> grid[i];
		REP(n)
		{
			W[0][i] = (grid[0][i] == '*' ? 0 : 1);
			W[i][0] = (grid[i][0] == '*' ? 0 : 1);
		}
		for (int i=1; i<n; i++)
		{
			for (int j=1; j<n; j++)
			{
				if (grid[i][j] == '*')
				{
					W[i][j] = 0;
				} else {
					W[i][j] = min(W[i-1][j-1], min(W[i-1][j], W[i][j-1])) + 1;
					maxWidth = max(maxWidth, W[i][j]);
				}
			}
		}
		
		cout << maxWidth << endl;
	}
	
	return 0;
}

Measured memory_bytes: 6044
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long long ans = 0;
 
    //Search for all i
    for (int i = 0; i < N; i++)
    {
        //Update the values of A[i+1] ... A[N]
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 4056
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], M = I[1], C = I[2];
		var B = G;
		var ans = 0;
		while (N-- > 0)
		{
			var A = G;
			var sum = C;
			for (var i = 0; i < M; i++) sum += A[i] * B[i];
			if (sum > 0) ans++;
		}
		WriteLine(ans);
	}
}


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

int main(){
char c;
  cin >> c;

  if((c == 'a') || (c == 'i') || (c == 'u') || (c == 'e') || (c == 'o')){
  cout << "vowel" << endl;
  }
  else{
  cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

//Monster Factory
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			char[] r = sc.next().toCharArray();
			if(r[0]=='-')break;
			char[] g = sc.next().toCharArray();
			char[] t = sc.next().toCharArray();
			StringBuilder sb = new StringBuilder();
			int k = 0;
			int ri = -1;
			int gi = 0;
			char c = g[0];
			while(true){
				if(k<t.length){
					if(c==t[k]){
						k++;
						c=r[++ri];
					}
					else {
						sb.append(c);
						c = g[++gi];
					}
				}
				else{
					if(ri<r.length)sb.append(r[ri]);
					while(++gi<g.length)sb.append(g[gi]);
					break;
				}
			}
			System.out.println(sb.toString());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using ll = long long;

ll SumFrom1ToN(ll n)
{
    return (1 + n) * n / 2;
}

int main()
{
    using namespace std;

    while (true)
    {
        int n;
        cin >> n;

        if (n == 0)
            break;

        vector<ll> a(n);
        for (auto& e : a)
            cin >> e;

        auto sum = accumulate(a.cbegin(), a.cend(), 0ll);
        auto mean = sum / n;
        auto c = count_if(a.cbegin(), a.cend(), [mean](auto x){return x <= mean;});

        cout << c << endl;
    }

    return 0;
}


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


h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]

xy = {}
for x, ai in enumerate(a):
    for y, aij in enumerate(ai):
        xy[aij] = (x, y)

acc = [[0] for _ in range(d)]
for num in range(d + 1, h * w + 1):
    (x, y), (i, j) = xy[num - d], xy[num]
    cost = abs(x - i) + abs(y - j)
    acc[num % d].append(acc[num % d][-1] + cost)

for l, r in lr:
    ans = acc[r % d][(r - 1) // d] - acc[l % d][(l - 1) // d]
    print(ans)


Measured memory_bytes: 106804
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int64 X,Y;
void Solve() {
    read(X);read(Y);
    if(abs(X - Y) <= 1) {
	puts("Brown");
    }
    else {
	puts("Alice");
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << endl;
  return 0;
}


Measured memory_bytes: 3600
def main():
  N=int(input())  #数値入力
  H=list(map(int, input().split()))  #リスト入力
  
  max_height=H[0]
  count=0
  
  for i in range(N):
    if H[i]>=max_height:
      count=count+1
      max_height=H[i]

  print(count)
    
main()

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>

#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int MOD = 998244353;

int main(){
    int n;
    cin >> n;
    map<int,int> m;
    vector<int> ds(n);
    
    rep(i,n){
        int d;
        cin >> d;
        ds[i] = d;
        m[d]++;
    }
    if (ds[0] != 0 || m[0] != 1){
        cout << 0; rn 0;
    }
    ll ans = 1;
    for(auto w:m){
        if (w.first != 0){
            rep(i,w.second){
                ans *= m[w.first-1];
                ans %= 998244353;
                }
        }
    }
    cout << ans;
    rn 0;
}


Measured memory_bytes: 5376
def check(N, S, ans):
    for i in range(N):
        if (ans[i] == "S") ^ (S[i] == "o"):
            if ans[(i-1) % N] == ans[(i+1) % N]:
                return False
        else:
            if ans[(i-1) % N] != ans[(i+1) % N]:
                return False
    return True


def main():
    N = int(input())
    S = input()
    initials = ["SS", "SW", "WS", "WW"]
    for init in initials:
        ans = [""] * N
        ans[0] = init[0]
        ans[1] = init[1]
        for i in range(1, N-1):
            if (ans[i] == "S") ^ (S[i] == "o"):
                ans[i+1] = "W" if ans[i-1] == "S" else "S"
            else:
                ans[i+1] = ans[i-1]
        if check(N, S, ans):
            print("".join(ans))
            return
    print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 44912
x, y = gets.split.map(&:to_i)

answer = 0

answer +=
  case x
  when 3
    100000
  when 2
    200000
  when 1
    300000
  else
    0
  end

answer +=
  case y
  when 3
    100000
  when 2
    200000
  when 1
    300000
  else
    0
  end

answer += 400000 if x == 1 && y == 1

puts answer 


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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  if(n >= 3200) cout << s << endl;
  else cout << "red" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()

bool eval(vector<int> &table,string s,int &i){
    if(isdigit(s[i])) return s[i++] == '1';
    if(s[i] == '-') return !eval(table,s,++i);
    if(isalpha(s[i])) return table[s[i++]-'a'];
    i++; // (
    bool e1 = eval(table,s,i);
    char op = s[i++];
    bool e2 = eval(table,s,i);
    i++; // )
    if(op == '^') return e1^e2;
    if(op == '*') return e1*e2;
    assert(false);
}

int feature(string &E){
    int k = 0;
    int f = 0;
    rep(a,2)rep(b,2)rep(c,2)rep(d,2){
        vector<int> table = {a,b,c,d};
        int i = 0;
        if(eval(table,E,i)){
            f |= 1<<k;
        }
        k++;
    }
    return f;
}

int main(void){
    vector<string> exps[17];
    exps[1] = {"a","b","c","d"};
    for(int m = 2; m <= 16; m++){
        for(string E : exps[m-1]){
            if(E[0] == '-') continue;
            exps[m].push_back("-"+E);
        }
        rep1(x,m-2){
            int y = m-3-x;
            if(x>y) continue;
            for(string E1 : exps[x]){
                for(string E2 : exps[y]){
                    bool ng = false;
                    for(char ch : {'a','b','c','d'}){
                        if(count(all(E1),ch)+count(all(E2),ch)>1){
                            ng = false;
                        }
                    }
                    if(ng) continue;
                    exps[m].push_back("("+E1+"^"+E2+")");
                    exps[m].push_back("("+E1+"*"+E2+")");
                }
            }
        }
    }
    exps[1].push_back("0");
    exps[1].push_back("1");


    vector<int> min_len(1<<16, 20);
    rep1(m,16){
        for(string E : exps[m]){
            int f = feature(E);
            min_len[f] = min(min_len[f], m);
        }
    }

    string E;
    while(cin>>E, E != "."){
        cout<<min_len[feature(E)]<<endl;
    }
    return 0;
}



Measured memory_bytes: 13344
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  bool flag = true;
  if(S[0] != 'A') flag = false;
  if(S[1] < 'a' || S[N-1] < 'a' || S[1] > 'z' || S[N-1] > 'z') flag = false;
  int cnt = 0;
  for(int i = 2; i < N-1; i++){
    if(S[i] < 'a' || S[i] > 'z'){
      if(S[i] != 'C'){
        flag = false;
      }else{
        cnt++;
      }
    }
  }
  if(cnt == 1 && flag){
    cout << "AC" << endl;
  }else{
    cout << "WA" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define Pair pair<int,int>


int H,W,D,Q;

vector<int> L, R;

vector<Pair> A;

vector<int> Ans;



void sub_solve(){
	for(int i=1;i<=D;i++){
		Ans[i] = 0;
	}

	for(int i=D+1;i<=H*W;i++){
		Ans[i] = Ans[i-D] + abs(A[i].first - A[i-D].first) + abs(A[i].second - A[i-D].second);
	}
	
}

void solve(){
	sub_solve();
	
	for(int i=0;i<Q;i++){
		cout << Ans[R[i]] - Ans[L[i]] << endl;
	}

}


int main(){
	cin >> H >> W >> D;
	A.resize(H*W+1); Ans.resize(H*W+1);
	int a;
	for(int i=1;i<H+1;i++){
		for(int j=1;j<W+1;j++){
			cin >> a;
			A[a] = {i,j};
		}
	}

	cin >> Q;
	R.resize(Q); L.resize(Q);

	for(int i=0;i<Q;i++){
		cin >> L[i] >> R[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
 
public class Main {
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    void solve() throws IOException {
    	int a = ni();
    	int b = ni();
    	int h = ni();
    	
    	out.println((a + b) * h / 2);
    }
 
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 8020
S = input()
Q = int(input())
Q_list = list()
for i in range(Q):
    Q_list.append(input().split())

from collections import deque
def operate(i):
    global count, str_list
    if Q_list[i][0] == '1':
        count += 1
    else:
        if count % 2 == 0:
            if Q_list[i][1] == '1':
                str_list.appendleft(Q_list[i][2])
            else:
                str_list.append(Q_list[i][2])
        else:
            if Q_list[i][1] == '1':
                str_list.append(Q_list[i][2])
            else:
                str_list.appendleft(Q_list[i][2])

check = 0
for i in range(Q):
    if Q_list[i][0] == '1':
        check += 1

S_list = [i for i in S]
if check % 2 == 1:
    S_list = list(reversed(S_list))

S_n = ''.join(S_list)

str_list = deque()
str_list.append(S_n)
count = check%2
for i in range(Q):
    operate(i)
print(''.join(str_list))


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

using namespace std;

int main()
{
    int a,b,c,i,flag=0;
    cin >> a >> b >> c;
    for(i=1;i<=b;i++)
    {
        if(a*i%b==c)
        {
            flag=1;
            break;
        }

    }
    if(flag==1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

ans = 0
cnt = 0
buf = h[0]
for i in range(1, n):
    if buf >= h[i]:
        cnt += 1
        buf = h[i]
    else:
        ans = max(ans, cnt)
        cnt = 0
        buf = h[i]
ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  for (int i = 1; i <= 5; ++i) {
    int x;
    cin >> x;
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
  }
  assert(false);
  return 0;
}


Measured memory_bytes: 3504
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long a[100010];
int main() {
	long long n, l;
	cin >> n >> l;
	long long m = l - 1, co;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		if (m < a[i] + a[i + 1]) {
			m = a[i] + a[i + 1];
			co = i + 1;
		}
	}
	if (m < l) {
		cout << "Impossible" << endl;
	}
	else {
		cout << "Possible" << endl;
		for (int i = 1; i < co; i++) {
			cout << i << endl;
		}
		for (int i = n - 1; i > co; i--) {
			cout << i << endl;
		}
		cout << co << endl;
	}
}


Measured memory_bytes: 4356
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

#[derive(Clone, Debug)]
struct UnionFind {
  par: Vec<usize>,
  size: Vec<usize>,
}

impl UnionFind {
  fn new(n: usize) -> Self {
    let mut uf = UnionFind {par: vec![0; n], size: vec![1; n]};
    for (i, item) in uf.par.iter_mut().enumerate() {
      *item = i;
    }
    uf
  }
  fn find(&mut self, x: usize) -> usize {
    if self.par[x] == x {
      x
    } else {
      let px = self.par[x];
      self.par[x] = self.find(px);
      self.par[x]
    }
  }
  fn unite(&mut self, x: usize, y: usize) {
    let x = self.find(x);
    let y = self.find(y);
    if x == y {
      return;
    }
    if self.size[x] < self.size[y] {
      self.par[x] = y;
      self.size[y] += self.size[x];
    } else {
      self.par[y] = x;
      self.size[x] += self.size[y];
    }
  }
  fn same(&mut self, x: usize, y: usize) -> bool {
    self.find(x) == self.find(y)
  }
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    m: usize,
    k: usize,
    fr: [(usize1, usize1); m],
    bl: [(usize1, usize1); k],
  }
  let mut uf = UnionFind::new(n);
  for &(a, b) in &fr {
    uf.unite(a, b);
  }
  let mut fr_a = vec![vec![]; n];
  let mut bl_a = vec![vec![]; n];
  for &(a, b) in &fr {
    fr_a[a].push(b);
    fr_a[b].push(a);
  }
  for &(c, d) in &bl {
    bl_a[c].push(d);
    bl_a[d].push(c);
  }
  for i in 0 .. n {
    let root = uf.find(i);
    let mut s = uf.size[root] - fr_a[i].len() - 1;
    for &b in &bl_a[i] {
      if uf.same(i, b) {
        s -= 1;
      }
    }
    puts!("{} ", s);
  }

  puts!("\n");
}


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

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

  // a[i]=x[i]+y[i], b[i]=x[i]-y[i]
  // max(max(a[i]-a[j]),max(b[i]-b[j]))
  int a_min = INT_MAX, a_max = -INT_MAX;
  int b_min = INT_MAX, b_max = -INT_MAX;
  int x, y;
  rep(i, N) {
    cin >> x >> y;
    int a = x + y;
    int b = x - y;
    a_min = min(a, a_min);
    a_max = max(a, a_max);
    b_min = min(b, b_min);
    b_max = max(b, b_max);
  }
  cout << max(a_max - a_min, b_max - b_min) << endl;
  return 0;
}

Measured memory_bytes: 3632
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    string str;
    cin>>str;
    if(str.find("A") != string::npos && str.find("B") != string::npos)
        cout<<"Yes";
    else
        cout<<"No";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3604
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
template<typename V> typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

bool isPrime(int n) {
  if (n == 1) return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}

int f(int n, int p) {
  int l = n + 1;
  vi v;
  v.reserve(100);
  for (int i = n + 1, x = 0; x < 100; i++) {
    if (isPrime(i)) v.pb(i), x++;
  }
  vi w;
  w.reserve(10000);
  rep(i, 100) loop(j, i, 100) w.pb(v[i] + v[j]);
  sort(all(w));
  return w[p - 1];
}

void solve() {
  int n, p;
  while (cin >> n >> p, n >= 0) cout << f(n, p) << endl;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//---------------from here-----------------

int main(){
    int a,b,k; cin>>a>>b>>k;
    int cnt=0;
    int ans=0;
    vector<int> vec;
    for(int i=1; i<=max(a,b); i++){
        if(a%i==0 && b%i==0) vec.push_back(i);
    }
    sort(all(vec));
    reverse(all(vec));

    cout<<vec[k-1]<<endl;
}

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

int main(){
  int n,i,j,x,w;
  int *A;
  scanf("%d",&n);
  A=(int *)malloc((n+1)*sizeof(int));
  for(i=1;i<=n;i++) scanf("%d",&A[i]);
  x=A[n];
  i=0;
  
  for(j=1;j<=n-1;j++){
    
    if(A[j]<=x){
      i++;
      w=A[i];
      A[i]=A[j];
      A[j]=w;
    }
  }
  w=A[i+1];
  A[i+1]=A[n];
  A[n]=w;
  
  for(j=1;j<=n;j++){
    if(j==i+1)printf("[%d]",A[j]);
    else printf("%d",A[j]);
    if(j!=n) printf(" ");
  }
  printf("\n");
  return 0;
}



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

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

int main()
{
    ll i,j;
    ll x;
    cin >> x;
    ll tmp = lcm(x, 360);
    cout << tmp/x << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7, iv2=(mod+1)/2;

int f[3333][3333], g[3333][3333];

int n, q, a[3333];

int main(){
  cin>>n>>q;
  for (int i=1;i<=n;++i) cin>>a[i];
  for (int i=1;i<=n;++i)
    for (int j=1;j<=n;++j)
      if (i!=j) f[i][j]= a[i]>a[j];
  
  ll pw=1;
  for (int x,y;q--;){
    cin>>x>>y;
    for (int i=1;i<=n;++i)
      if (i!=x&&i!=y){
        // i,x  i,y  x,i  y,i
        g[i][x]=(f[i][x]+f[i][y])*(ll)iv2%mod;
        g[i][y]=(f[i][x]+f[i][y])*(ll)iv2%mod;
        g[x][i]=(f[x][i]+f[y][i])*(ll)iv2%mod;
        g[y][i]=(f[x][i]+f[y][i])*(ll)iv2%mod;
      }
    f[x][y]=f[y][x]=(f[x][y]+f[y][x])*(ll)iv2%mod;
    for (int i=1;i<=n;++i)
      if (i!=x&&i!=y){
        // i,x  i,y  x,i  y,i
        f[i][x]=g[i][x];
        f[i][y]=g[i][y];
        f[x][i]=g[x][i];
        f[y][i]=g[y][i];
      }
    pw=pw*2%mod;
  }
  ll ans=0;
  for (int i=1;i<=n;++i)
    for (int j=i+1;j<=n;++j)
      ans=(ans+f[i][j])%mod;
  
  ans=ans*pw%mod;
  cout<<ans<<endl;
}


Measured memory_bytes: 82304
def gcd(x, y):
    while y > 0:
        tmp = x % y
        x = y
        y = tmp
    return x

def lcm(x, y):
    if x == 0 or y == 0:
        return 0
    else:
        return x // gcd(x, y) * y

def main():
    mod = int(1e9 + 7)
    n = int(input())
    a = list(map(int, input().split()))
    l = 1
    for i in range(n):
        l = lcm(l, a[i])

    ans = 0

    for i in range(n):
        ans += l // a[i]

    ans %= mod

    print(int(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007
using namespace std;
int main(){
    ll n;
    cin>>n;
    ll a[n];
    ll sum = 0;
    for(ll i = 0;i<n;i++){
        cin>>a[i];
        sum += a[i];
    }
    ll ans = 0;
    for(ll i= 0;i<n;i++){
        sum = sum - a[i];
        ans = ans%M + ( (sum%M)*(a[i]%M))%M;
    }
    cout<<ans%M<<endl;
}


Measured memory_bytes: 5192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int[] packet=new int[52];
		int INF=1000000007;
		Arrays.fill(packet, INF);
		packet[0]=0;
		for(int i=1; i<52; i++) {
			if(i-2>=0 && packet[i-2]<INF) {
				packet[i]=Math.min(packet[i], packet[i-2]+380);
			}
			if(i-3>=0 && packet[i-3]<INF) {
				packet[i]=Math.min(packet[i], packet[i-3]+550);
			}
			if(i-5>=0 && packet[i-5]<INF) {
				packet[i]=Math.min(packet[i], packet[i-5]+850);
			}
			if(i-10>=0 && packet[i-10]<INF) {
				packet[i]=Math.min(packet[i], packet[i-10]+1520);
			}
			if(i-12>=0 && packet[i-12]<INF) {
				packet[i]=Math.min(packet[i], packet[i-12]+1870);
			}
			if(i-15>=0 && packet[i-15]<INF) {
				packet[i]=Math.min(packet[i], packet[i-15]+2244);
			}
		}
		while(true) {
			int a=sc.nextInt()/100;
			if(a==0) {
				System.exit(0);
			}
			else {
				pl(packet[a]);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


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

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

using namespace std;

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

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

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

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


/*FUNCs=================================================*/


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

    string s,t;
    i32 n,m;
    cin >> n >> m;
    cout << n * m << '\n';




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


Measured memory_bytes: 3608
# include "bits/stdc++.h"
 
using namespace std;
 
#define endl "\n"
typedef long long int ll;
#define f first
#define s second
 
inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}
 
//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
 
ll INF = 1e10;
int MOD = 1e9+7;

int main(){
    fastio();

    int n;
    cin >> n;

    int cnt = 0;
    int min_yet = 1e9;
    for(int i = 0; i < n; ++i){
    	int t;
    	cin >> t;
    	if(t < min_yet){
    		cnt ++;
    		min_yet = t;
    	}
    }

    cout << cnt;

    return 0;
}

/*

*/

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    int a[n]; rep(i,n) cin>>a[i];
    int b[n]; rep(i,n) cin>>b[i];
    int ans=0;
    // 解の下位ibit目
    for(int i=0;i<29;i++){
        // mod2^(i+1)
        int k=1<<(i+1);
        int t=1<<i;
        int bb[n]; rep(j,n) bb[j]=b[j]%k;
        sort(bb,bb+n);
        // rep(j,n) cout<<bb[j]<<" ";
        // cout<<endl;
        int cnt=0;
        rep(j,n){
            int aa=a[j]%k;
            // printf("[%d,%d):%d-%d\n",t-aa,2*t-aa,lower_bound(bb,bb+n,2*t-aa),lower_bound(bb,bb+n,t-aa));
            // printf("[%d,%d):%d-%d\n",3*t-aa,4*t-aa,lower_bound(bb,bb+n,4*t-aa),lower_bound(bb,bb+n,3*t-aa));
            cnt+=lower_bound(bb,bb+n,2*t-aa)-lower_bound(bb,bb+n,t-aa);
            cnt+=lower_bound(bb,bb+n,4*t-aa)-lower_bound(bb,bb+n,3*t-aa);
        }
        if(cnt%2) ans+=(1<<i);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	long long A1, A2, B1, B2, T1, T2, D1, D2, D3, p, q;
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
	D1 = (A1 - B1) * T1;
	D2 = (A2 - B2) * T2;

	if (D1 < 0) {
		D1 *= -1; D2 *= -1;
	}
	if (D1 + D2 > 0) {
		cout << 0;
	}
	else if (D1 + D2 == 0) {
		cout << "infinity";
	}
	else {
		// D1 + D2 < 0
		// abs(D1) < abs(D2)
		D3 = -(D1 + D2);
		p = D1 / D3, q = D1 % D3;
		if (q) cout << p * 2 + 1;
		else cout << p * 2;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
Vi solve(ll n){
	if(n==1)return Vi{};
	if(n&1){Vi s=solve(n-1);s.insert(s.begin(),SZ(s)+1);return s;}
	Vi s=solve(n/2);s.pb(SZ(s)+1);return s;
}

int main() {
	ll n;read(n);Vi s=solve(n+1);
	printf("%d\n",2*SZ(s));
	rep(i,0,SZ(s)-1)printf("%d ",s[i]);
	rep(i,0,SZ(s)-1)printf("%d ",i+1);
	return 0;
}


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

string func(string s){
	for(int a = 1;;a++){
		for(int b = 0;b < 26;b++){
			string t = s;
			for(int i = 0;i < s.size();i++){
				if(t[i] != ' '){
					t[i] = (a*(t[i]-'a') + b) % 26 + 'a';
				}
			}
			if(t.find("this") != -1 || t.find("that") != -1)return t;
		}
	}
}

int main(){
	int n;cin >> n;
	string s;
	getline(cin, s);
	while(n--){
		getline(cin, s);
		cout << func(s) << endl;
	}
	return 0;
}
/*
1
y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
*/

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

typedef long long ll;
const ll INF = 1LL << 60;
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint mod_pow(ll x, ll n) {
    mint res = 1;
    while (n > 0) {
        if (n & 1) res = res * x;
        x = x * x;
        n >>= 1;
    }
    return res;
} 

mint choose(ll n, ll a) {
    mint x = 1, y = 1;
    rep(i, a) {
        x *= (n - i);
        y *= (i + 1);
    }

    return x / y;
}
int n, a, b;
int main() {
    cin >> n >> a >> b;
    mint total(2);
    mint ans = total.pow(n);
    ans -= 1;
    ans -= choose(n, a);
    ans -= choose(n, b);
    cout << ans.x << endl;
}

Measured memory_bytes: 256
integers = int(input())

thousand = int(integers/1000)
hundred = int((integers-thousand*1000)/100)
ten = int((integers-thousand*1000-hundred*100)/10)
one = integers - thousand*1000-hundred*100-ten*10


if(thousand == hundred and hundred == ten):
    print("Yes")
elif(hundred == ten and ten == one):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>

#define HMAX 2000001

int H,A[HMAX];

void maxHeapify(int i){

  int l,r,largest,temp;
  l = i * 2;
  r = i * 2 + 1;

  if(l <= H && A[l] > A[i]){
    largest = l;
  }else{
    largest = i;
  }
  if(r <= H && A[r] >A[largest]){
    largest = r;
  }

  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(largest);
  }
}

int main(void){
  int i;
 
  scanf("%d",&H);

  for(i = 1;i <= H;i++){
    scanf("%d",&A[i]);
  }
  for(i = H / 2;i >= 1;i--){
    maxHeapify(i);
  }

  for(i = 1;i <= H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}

    
		   



Measured memory_bytes: 3724
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long A, B, K;
  scanln(A, B, K);

  long a = A - K;
  K -= A;
  long b = B;
  if (K > 0) {
    b -= K;
  }
  writeln(
    max(0, a),
    " ",
    max(0, b)
  );
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n,a[100];
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	sort(a,a+n);
	reverse(a,a+n);
	int x = 0;
	for(int i=0;i<n;i++){
		if(i%2==0) x += a[i];
		else x -= a[i];
	}
	printf("%d\n",x);
}


Measured memory_bytes: 128
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
arr=arr.map(v=>v.split(" ").map(Number));
var n=arr.shift() - 0;
var a = arr.shift();
var k=n-1;
var flag=false;
for(var i=0;i<a.length;i++){
   for(var j=i+1;j<a.length;j++){
      if(Math.abs(a[i]-a[j])%k==0){
         console.log(a[i] + " " + a[j]);
         flag = true;
         break;
      }
   }
    if(flag)break;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    sort(p.begin(), p.end());
    int sum = 0;
    for(int i = 0; i < k; i++) sum += p[i];
    cout << sum << endl;
}

Measured memory_bytes: 3560