akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;

signed main(){
    llin(sx);
    llin(sy);
    llin(lx);
    llin(ly);
    str r(lx-sx,'R');
    str u(ly-sy,'U');
    str l(lx-sx,'L');
    str d(ly-sy,'D');
    sal(r+u+l+d+"DR"+r+u+"ULUL"+l+d+"DR")
}


Measured memory_bytes: 256
let css = Array.init 3 @@ fun _ -> Array.init 3 @@ fun _ -> Scanf.scanf " %d" (+) 0
let bs = Array.init 3 @@ fun i -> css.(0).(i)
let a_s = Array.init 3 @@ fun i -> css.(i).(0) - css.(0).(0)
let _ =
  for i = 0 to 2 do
    for j = 0 to 2 do if css.(i).(j) <> a_s.(i) + bs.(j) then (print_endline "No"; exit 0) done done;
  print_endline "Yes"

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;


int h, w;
char grid[50][50];

int diri[] = {-1, 1, 0, 0};
int dirj[] = {0, 0, -1, 1};

int main(){
    cin >> h >> w;

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> grid[i][j];
        }
    }

    bool ans = true;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (grid[i][j] == '.') continue;
            bool ng = true;
            for (int k = 0; k < 4; ++k) {
                int ni = i + diri[k];
                int nj = j + dirj[k];
                if (ni < 0 || ni == h) continue;
                if (nj < 0 || nj == w) continue;
                if (grid[ni][nj] == '#') ng = false;
            }
            if (ng) {
                 ans = false;
                 //cout << i << j << endl;
            }
            if (!ans) break;
        }
        if (!ans) break;
    }

    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
S = input()
T = ''
i = 0

while len(T) < len(S):
    if S[i:i+6] == 'eraser':
        T += 'eraser'
        i += 6
    elif S[i:i+5] == 'erase':
        T += 'erase'
        i += 5
    elif S[i:i+5] == 'dream':
        if S[i+5:i+6] == 'd':
            T += 'dream'
            i += 5
        elif S[i+5:i+8] == 'era':
            T += 'dream'
            i += 5
        elif S[i+5:i+6] == '':
            T += 'dream'
            i += 5
        elif S[i+5:i+8] == 'ere':
            T += 'dreamer'
            i += 7
        elif S[i+5:i+8] == 'erd':
            T += 'dreamer'
            i += 7
        elif S[i+5:i+8] == 'er':
            T += 'dreamer'
            i += 7
        else:
            T += 'dream'
            i += 5
    else:
        print('NO')
        exit()

print('YES')

Measured memory_bytes: 3188
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            var N = Sarray()[0];
            grf = new int[N].Select(_ => new List<long>()).ToArray();
            for (var i = 0; i < N - 1; ++i) 
            {
                var stw = Sarray();
                --stw[0];--stw[1];
                grf[stw[0]].Add(stw[1]);
                grf[stw[1]].Add(stw[0]);
            }
            dptree = new double[N];
            prob = 1.0d / N;

            dfs(0, -1);
            dp = new double[N];
            maxdfs(0, 0, 0);
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            for (var i = 0; i < N; ++i)
                WriteLine(dp[i]);
            Console.Out.Flush();
        }
        static List<long>[] grf;
        static double[] dptree;
        static double[] dp;
        static double prob;
        static void dfs(long n, long p)
        {
            double deno = 0.0;
            if (0 <= p)
                deno = prob * (grf[n].Count - 1);
            else
                deno = prob * grf[n].Count;
            if (deno <= 0) return;
            double nume = 0.0;
            foreach (var next in grf[n])
            {
                if (next == p) continue;
                dfs(next, n);
                nume += dptree[next];
            }
            dptree[n] = prob * nume / deno + 1.0;
        }
        static void maxdfs(long n, long p, double pinfo)
        {
            double deno = prob * grf[n].Count;
            double nume = 0.0;
            foreach (var next in grf[n])
            {
                if (next == p)
                {
                    nume += pinfo;
                    continue;
                }
                nume += dptree[next];
            }
            dp[n] = prob * nume / deno + 1.0;
            foreach (var next in grf[n])
            {
                if (next == p) continue;
                if (grf[n].Count == 1)
                    maxdfs(next, n, 0);
                else
                    maxdfs(next, n, prob * (nume - dptree[next]) / (deno - prob) + 1);
            }
        }
    }
}

Measured memory_bytes: 56000
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int k, a, b;
    cin >> k >> a >> b;
    int kk(k);
    while (kk <= b) {
        if (kk >= a){
            cout << "OK" << endl;
            break;
        }
        kk += k;
    }
    if (kk > b) {
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)
#include <set>

using namespace std;
#define ll long long

int f(int s) {
  if(s % 2 == 0)
    return s / 2;
  else
    return 3 * s + 1;
}

int main(){
  int s;
  cin >> s;
  int i = 1;
  set<int> S;
  while(true) {
    if(S.find(s) != S.end()) {
      cout << i << endl;
      break;
    } else {
      S.insert(s);
      s = f(s);
      i++;
    }
  }
  return 0;
}


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

N,K = map(int,input().split())
*A, = map(int,input().split())
*F, = map(int,input().split())

F.sort(reverse=True)
A.sort()

def check(n):
    if n==-1: return False
    cost = 0
    for a,f in zip(A,F):
        if a*f>n:
            cost += a - n//f
    return cost <= K

l = -1
r = 10**13
while l+1<r:
    i = (l+r)//2
    if check(i):
        r = i
    else:
        l = i

print(r)

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

using ll = long long;

const int MOD = int(1e9)+7;

int modinv(int a, int m) {
  return (a == 1) ? 1 : m - int(ll(modinv(m % a, a)) * m / a);
}

int fact(int n) {
  int res = 1;
  for (int i = 1; i <= n; i++) res = int(ll(res) * i % MOD);
  return res;
}

int choose(int n, int r) {
  if (r<0 || r>n) return 0;
  return ll(fact(n)) * modinv(ll(fact(r)) * ll(fact(n-r)) % MOD, MOD) % MOD;
}

int solve(int N, int K) {
  int ans = choose(N-1+K-1, K-1) - choose(N-1+K-1, K-2);
  if (ans < 0) ans += MOD;
  for (int i = K+1; i <= N-1; i++) {
    ans *= 2;
    if (ans >= MOD) ans -= MOD;
  }
  return ans;
}

int main() {
  int N, K; cin >> N >> K;
  cout << solve(N, K) << '\n';
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int a, b, c;
	cin >> a >> b >> c;

	if (a > b) {
		swap(a, b);
	}

	if (a <= c && c <= b) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

using ll = long long;
#define rep(n, i) for(ll i = 0; i < n; ++i)

void solve(void){
  string s; cin >> s;

  ll r = 0, b = 0;
  rep((ll)s.size(), i) {
    if (s[i] == '0') ++r;
    else ++b;
  }

  cout << min(r, b) * 2 << endl;
}

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


Measured memory_bytes: 512
<?php
fscanf(STDIN, "%d", $N);
$ans = 0;
$p = explode(" ", trim(fgets(STDIN)));
for ($i = 1; $i < $N - 1; $i++) {
    $r1 = $p[$i - 1] > $p[$i];
    $r2 = $p[$i + 1] > $p[$i];
    if ($r1 !== $r2) {
        $ans++;
    }
}
echo $ans;


Measured memory_bytes: 4984
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    int k, n;
    std::cin >> k >> n;
    std::vector<int> a(n);
    rep(i, n) std::cin >> a[i];
    std::vector<int> sa;
    rep(i, n - 1) {
        sa.emplace_back(a[i + 1] - a[i]);
    }
    sa.emplace_back((k - a[n - 1]) + a[0]);
    int ans = *std::max_element(sa.begin(), sa.end());
    std::cout << k - ans << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 2168
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    ll blue = 0;
    ll couple = N / (A + B);
    blue+= couple * A;
    N-=couple * (A + B);
    if(N <= A) blue += N;
    else blue += A;
    cout << blue << endl;
}


Measured memory_bytes: 3512
l,r=map(int,input().split())
i=1
temp=0
while r>2019*i:
  if l<=2019*i:
    temp=1
    break
  i=i+1

count=2019
r=r%2019
l=l%2019
for i in range(l,r+1):
  for j in range(i+1,r+1):
    temp1=(i*j)%2019
    count=min(count,temp1)

if temp==1:
  print(0)
else:
  print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <map>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    map<ll, ll> m;
    for(int i=1; i<=N; i++){
        int d = i % K;
        if(m.count(d) == 0) m[d] = 1;
        else m[d]++;
    }

    ll ans;
    ans = m[0]*m[0]*m[0];
    if(K %2 == 0){
        ans += m[K/2]*m[K/2]*m[K/2];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6528
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim n As Integer = NextInt()
        Dim c As Integer = NextInt()
        Dim k As Integer = NextInt()
        Dim t(n - 1), ans, waitStart, waitPeople As Integer

        For i As Integer = 0 To n - 1
            t(i) = NextInt()
        Next
        Array.Sort(t)

        For i As Integer = 0 To n - 1
            If t(i) - waitStart > k OrElse waitPeople = c Then
                waitPeople = 0
            End If
            waitPeople += 1

            If waitPeople = 1 Then
                waitStart = t(i)
                ans += 1
            End If
        Next

        WriteLine(ans)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-5;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const int64 mod = 1e9+7;

int main(void) {
	int64 H, W, K;
	cin >> H >> W >> K; K--;
	vector<int64> dp(W, 0);
	dp[0] = 1;
	REP(i, H) {
		vector<int64> dp2(W, 0);
		REP(j, 1 << (W-1)) {
			bool ok = 1;
			REP(k, W) {
				if ((j >> k & 3) == 3) ok = 0;
			}
			if (!ok) continue;
			REP(k, W) {
				if (k > 0 && j >> (k-1) & 1)
					(dp2[k-1] += dp[k]) %= mod;
				else if (k < W-1 && j >> k & 1)
					(dp2[k+1] += dp[k]) %= mod;
				else
					(dp2[k] += dp[k]) %= mod;
			}
		}
		swap(dp, dp2);
	}
	cout << dp[K] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pll = pair<long long, long long>;
vector<pll> simplify(vector<pll> in){
	vector<pll> res, tmp;
	for(auto e : in){
		tmp.push_back({e.first, -1});
		tmp.push_back({e.second, 1});
	}
	sort(tmp.begin(), tmp.end());
	int len = tmp.size();
	for(int i = 0; i < len;){
		int j = i  - 1, sum = 0;
		while(j + 1 < len && sum - tmp[j + 1].second > 0) sum -= tmp[++j].second;
		assert(j + 1 < len && sum - tmp[j + 1].second == 0);
		res.push_back({tmp[i].first, tmp[j + 1].first});
		i = j + 2;
	}
	return res;
}
int main(){
	long long a, b;
	cin >> a >> b;
	if(a == b){
		cout << 1 << endl;
		return 0;
	}
	for(int i = 59; i >= 0; i--){
		if((a>>i) != (b>>i)){
			long long m = 1ll<<i;
			/**
			  [a, m - 1)
			  [m, b]
			  [m + a, 2 * m - 1]
			  **/
			vector<pll> ins;
			ins.push_back({a, m - 1});
			long long nb = 0;
			for(int j = i; j >= 0; j--){
				if((m | (1ll<<j)) <= b) nb |= 1ll<<j;
			}
			ins.push_back({m, nb});
			ins.push_back({m + a, 2 * m - 1});
			ins = simplify(ins);
			long long ans = 0;
			for(auto e : ins) ans += e.second - e.first + 1;
			cout << ans << endl;
			break;
		}
		a = min(a, a ^ (1ll<<i));
		b = min(b, b ^ (1ll<<i));
	}
	return 0;
}


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

public class Main
{

	public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws IOException
	{
		// TODO 自動生成されたメソッド・スタブ
		String str1[] = input(1);
		String str2[] = input(Integer.parseInt(str1[0]));
		String str3[] = input(1);
		String str4[] = input(Integer.parseInt(str3[0]));

		int ai[] = new int[Integer.parseInt(str1[0])];
		int bi[] = new int[Integer.parseInt(str3[0])];

		for(int i = 0; i < ai.length; i++)
		{
			ai[i] = Integer.parseInt(str2[i]);
		}

		for(int i = 0; i < bi.length; i++)
		{
			bi[i] = Integer.parseInt(str4[i]);
		}

		int temp = 0;

		for(int i = 0; i < bi.length; i++)
		{
			if(SeparateSearch(ai, bi[i], 0, ai.length-1)) temp++;
			//System.out.println(temp);
		}
		System.out.println(temp);
	}

	public static boolean SeparateSearch(int[] a, int b, int first, int end)
	{
		if(end - first <= 1)
		{
			if(a[first] == b) return true;
			else if(a[end] == b) return true;
			else return false;
		}
		else
		{
			int temp = (end + first) / 2;
			//System.out.println(a[temp] + " " + b + " " + first + " " + end + " " + (a[temp] < b));
			if(a[temp] == b) return true;
			else if(a[temp] < b) return SeparateSearch(a, b, temp, end);
			else return SeparateSearch(a, b, first, temp);
		}
	}

	public static int GCD(int x, int y)
	{
		int z = Math.max(x, y) % Math.min(x, y);
		if(z == 0) return Math.min(x, y);
		return GCD(z, Math.min(y, x));
	}

	public static String[] input(int Num) throws IOException
	{
		String str[] = new String[Num];
		String str2 = br.readLine();
		int j = 0;
		for(int i = 0; i < Num; i++)
		{
			if(i < Num - 1)
			{
				str[i] = str2.substring(j, str2.indexOf(" ", j));
				j = str2.indexOf(" ", j) + 1;
			}
			else
			{
				str[i] = str2.substring(j);
			}
		}
		return str;
	}

}



Measured memory_bytes: 49556
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main () {
    int H, W, N;
    cin >> H >> W >> N;

    vector<int> A(N + 1);
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
    }

    vector<vector<int>> ans(H);
    int h = 0;
    int w = 0;
    int num = 1;
    int c = 0;
    while (h < H) {
        ans[h].push_back(num);
        ++c;

        if (w == W - 1) {
            w = 0;
            ++h;
        }
        else {
            ++w;
        }

        if (c == A[num]) {
            ++num;
            c = 0;
        }
    }

    for (int i = 0; i < H; ++i) {
        if (i & 1) reverse(ans[i].begin(), ans[i].end());
        for (int j = 0; j < W; ++j) {
            cout << ans[i][j];

            if (j == W - 1) cout << endl;
            else cout << ' ';
        }
    }

    return 0;
}

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

int main(){
    int n,k;
    int ans = 1000000000;

    cin >> n >> k;
    vector<int> h(n);

    for(int i = 0;i<n;i++){
        cin >> h[i];
    }
    
    sort(h.begin(),h.end()); // 昇順ソート

    for(int i = 0;i+k-1<h.size();i++){
        int deff = h[i+k-1] - h[i];
        ans = (deff<ans?deff:ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
n,m,x=map(int, input().split())
c =[list(map(int, input().split())) for i in range(n)]
ch = [0 for i in range(m+1)]
ans = 10000000000
a,all = [],[]
for i in range(1,n+1):
    a.append(i)
for i in range(1,2**len(a)):
    b = []
    for j in range(len(a)):
        if (i >> j) &1 == 1:
            b.append(a[j])
    all.append(b)
for i in range(len(all)):
    ch = [0 for i in range(m+1)]
    for j in range(len(all[i])):
        k = all[i][j]-1
        ch = [x+y for (x,y) in zip(ch,c[k])]
    t = 0
    for j in range(1,m+1):
        if ch[j] < x:
            t = 1
    if t == 0 and ans > ch[0]:
        ans = ch[0]
if ans == 10000000000:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9524
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
	string str;
	cin >> str;
	for(int i=0;i<str.size();i++){
		if(str[i] <= 'C'){
			str[i] = str[i] + 23;
		}else{
			str[i] = str[i] - 3;
		}
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 1180
// https://atcoder.jp/contests/abc076/tasks/abc076_b
#include <bits/stdc++.h>
using namespace std;

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

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

  int out = 1;
  rep(i, N) {
    if (out < K)
      out *= 2;
    else
      out += K;
  }

  cout << out;
  return 0;
}


Measured memory_bytes: 256
from sys import stdin
from math import ceil
def main():
	readline=stdin.readline
	N=int(readline())
	a=list(map(int,readline().split()))
	b=list(map(int,readline().split()))

	count=0
	for i in range(N):  #一旦、任意のiについてa_iをb_iよりも大きくする。
		if a[i]<b[i]:   #その時の回数をcountとする。
			c=ceil((b[i]-a[i])/2)
			count+=c
			a[i]+=2*c

	for i in range(N):  #count以内の回数でbも大きくしていく。
		if b[i]<a[i]:   #上の手順後にa<=bならa_i<b_iのiについて
			d=a[i]-b[i] #a_iとb_iを同時に増やしていけばa=bにすることができ、
			b[i]+=d     #a>bなら逆転不可能でa=bにすることはできない。
			count-=d

	if count>=0:
		print("Yes")
	else:
		print("No")

if __name__=="__main__":
	main()

Measured memory_bytes: 4596
import std.stdio, std.string, std.conv, std.array, std.algorithm, std.math;

long calc(long x) {
    return x * (x + 1) / 2;
}

void main() {
    string s = readln.chomp;
    if (s[0] == '>') s = '<' ~ s;
    if (s[$-1] == '<') s ~= '>';
    auto g = s.group.array;
    long[] a = new long[g.length];
    foreach (i, x; g) {
        a[i] = x[1];
    }
    long ans;
    for (auto i = 0; i < a.length; i += 2) {
        if (a[i] < a[i+1]) {
            ans += calc(a[i]-1) + calc(a[i+1]);
        } else {
            ans += calc(a[i]) + calc(a[i+1]-1);
        }
    }
    ans.writeln;
}

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

long min(long a,long b){
    if (a<b)return a;
    else return b;
}

int main(void) {
	int n,k,a[105];
	//dp[i]:石がi個の時,Firstが勝つなら1,Secondが勝つなら0
	int dp[100005] = {0};
	int h = 0;
	
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++) scanf("%d",&a[i]);
	
	for (int i=0;i<=k;i++){
	    for (int j=0;j<n;j++){
	        if (i>=a[j]){
	            if (dp[i-a[j]]==0) dp[i] = 1;
	        }
	    }
	}
	
	if (dp[k]==1)printf("First\n");
	else printf("Second\n");
	return 0;
}

Measured memory_bytes: 512
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    n = input()
    ans = ""
    for c in n:
        if c == "1":
            ans += "9"
        if c == "9":
            ans += "1"
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> E;
const LL MOD = 1000000007LL;
bool grid[100][100];
int main() {
	int A, B;
	cin >> A >> B;
	cout << "100 100" << endl;
	for (int i = 0; i < 100; i++) {
		for (int j = 50; j < 100; j++) grid[i][j] = 1;
	}
	int x = 51, y = 1;
	for (int i = 1; i < A; i++) {
		grid[y][x] = 0;
		x += 2;
		if (x >= 99) x = 51, y += 2;
	}
	x = 1, y = 1;
	for (int i = 1; i < B; i++) {
		grid[y][x] = 1;
		x += 2;
		if (x >= 49) x = 1, y += 2;
	}
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			if (grid[i][j]) cout << "#";
			else cout << ".";
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<ll> a(N);
    int cnt = 0, cnt2 = 0, cnt4 = 0;
    for (int i = 0; i < N; i++){
        cin >> a[i];
        if (a[i] % 4 == 0){
            cnt4++;
        }
        else if (a[i] % 2 == 0) {
            cnt2++;
        }
        else {
            cnt++;
        }
    }
    if (cnt2 > 0 && cnt <= cnt4){
        cout << "Yes" << endl;
    }
    else if (cnt2 == 0 && cnt  <= cnt4 + 1){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
const int INF = 1e9;
const double pi = acos(-1.0);
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    string s; cin >> s;
    cout << s.substr(0,3) << endl;
    return 0;
}  

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

using namespace std;

long long inf=1000000007;

int main(){
	int n,m;
	cin>>n>>m;
	vector<vector<int>> graph(n+1);
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		graph.at(a).push_back(b);
		graph.at(b).push_back(a);
	}

	vector<int> sign(n+1,-1);

	queue<int> que;
	que.push(1);
	sign.at(1)=0;

	while(!que.empty()){
		int now=que.front();
		que.pop();

		for(auto next:graph.at(now)){
			if(sign.at(next)!=-1) continue;

			sign.at(next)=now;
			que.push(next);
		}
	}

	for(int i=1;i<=n;i++){
		if(sign.at(i)==-1){
			cout<<"No"<<endl;
			return 0;
		}
	}

	cout<<"Yes"<<endl;
	for(int i=2;i<=n;i++) cout<<sign.at(i)<<endl;

	return 0;
}


Measured memory_bytes: 10220
#include<iostream>

using namespace std;

int main(){

  int in;
  cin >> in;
  for(int i = 0; i < in; i++){
    int data[2];
    data[0] = data[1] = 0;
    int flg = 0;
    for(int i = 0; i < 10; i++){
      int num;
      cin >> num;
      if(data[0] < data[1]){
	int tmp = data[0];
	data[0] = data[1];
	data[1] = tmp;
      }
      if(num > data[0]) data[0] = num;
      else if(num > data[1]) data[1] = num;
      else flg = 1;
    }
    if(flg) cout << "NO"<< endl;
    else cout << "YES"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        N: u32,
        M: u32,
        A: [u32; M],
    }

    let sum: u32 = A.iter().sum();
    if sum > N {
        println!("-1");
    } else {
        println!("{}", N-sum);
    }
}


Measured memory_bytes: 2260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) cin >> a[i];
    ll ans = 0;
    rep(i, 0, 61) {
        ll sum1 = 0;
        rep(j, 0, n) {
            if (a[j] & (1LL << i)) sum1++;
        }
        ans += (((1LL << i) % MOD) * ((sum1 * (n - sum1)) % MOD)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
 
 int dp[3005][3005];

int main()
{
    string s,t;
    cin>>s>>t;
    for(int i=0;i<=s.size();i++)
    {
        dp[i][t.size()]=0;
    }
    for(int i=0;i<=t.size();i++)
    {
        dp[s.size()][i]=0;
    }
    for(int i=s.size()-1;i>=0;i--)
    {
        for(int j=t.size()-1;j>=0;j--)
        {
            if(s[i]==t[j])
            {
                dp[i][j]=1+dp[i+1][j+1];
            }
            else
            {
                dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
    
    int i=0,j=0;
    while(i<s.size() && j<t.size())
    {
        if(s[i]==t[j])
        {
            cout<<s[i];
            i++;j++;
        }
        else if(dp[i+1][j]>dp[i][j+1])
        {
            i++;
        }
        else if(dp[i][j+1]>=dp[i+1][j])
        {
            j++;
        }
    }
    
return 0;
}

Measured memory_bytes: 35456
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Long[] a = new Long[n];
        Long[] b = new Long[n];
        for (int i = 0; i < n; i++) {
            a[i] = Long.parseLong(sc.next());
            b[i] = Long.parseLong(sc.next());
        }
        sc.close();

        // 主処理
        long increase = 0;
        for (int i = n - 1; 0 <= i; i--) {
            long numA = a[i] + increase;
            long numB = b[i];
            if (numA != 0 && numA <= numB) {
                increase += numB - numA;
            } else {
                long num = (long) Math.ceil((double) numA / numB) * numB;
                increase += num - numA;
            }
        }
        long result = increase;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 66120
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

const int limit = 100010;
vector<int> num[2];
using pii = pair<int,int>;
vector<pii> ary[2];

int main(void){
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	
	const int m = n / 2;
	int ans = n;

	rep(i,2){
		num[i] = vector<int>(limit,0);
		rep(j,m) num[i][v[2 * j + i]]++;
	}

	rep(i,2){
		rep(j,limit) ary[i].push_back(pii(num[i][j],j));
		sort(rbegin(ary[i]),rend(ary[i]));
	}

	rep(i,2)rep(j,2){
		if(ary[0][i].second == ary[1][j].second) continue;
		chmin(ans, n - ary[0][i].first - ary[1][j].first);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N, K;
    cin >> N >> K;
    VLL h(N);
    rep(i,N){
        cin >> h[i];
    }
    sort(all(h));
    reverse(all(h));
    ll mini=INF;
    rep(i,N-K+1){
        mini=min(mini,h[i]-h[i+K-1]);
    }
    cout << mini << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector> 
using namespace std;
typedef long long ll;
ll x;
ll mul(ll a)
{
   ll sum=a*a*a*a*a;
   return sum;	
}
int main()
{
	ll x;
	cin>>x;
	ll i,j;
	for(i=0;i<=1000;i++)
	{
		for(j=0;j<=1000;j++)
		{
			ll n=mul(i);
			ll m=mul(j);
			ll k=n+m;
			ll y=n-m;
			ll z=m-n;
			if(k==x)
			{
				j=-j;
				cout<<i<<" "<<j;
				return 0;
			}
			if(y==x)
			{
				cout<<i<<" "<<j;
				return 0;
			}
			if(z==x)
			{
				cout<<j<<" "<<i;
				return 0;
			}
		}
	}
	return 0;
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

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

ll rl[510][510], sum[510][510];

int main(int argc, char **argv)
{
	ll N, M, Q; cin >> N >> M >> Q;
	REP(i, M)
	{
		ll a, b; cin >> a >> b;
		--a, --b;
		rl[a][b]++;
	}

	memset(sum, 0, sizeof sum);

	REP(i, N)
	{
		for (ll j = 1; j <= N; ++j)
			sum[i][j] = sum[i][j-1] + rl[i][j-1];
	}

	REP(_, Q)
	{
		ll l, r; cin >> l >> r;
		--l, --r;
		ll res{0};
		for (ll i = l; i <= r; ++i)
			res += sum[i][r+1] - sum[i][l];
		std::cout << res << std::endl;
	}
}


Measured memory_bytes: 4992
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 45
#define MAXM 131072
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll dp[MAXN][MAXM+100];
int n,x,y,z;
bool check(int t){
	if((t&(1<<(x+y+z-1)))!=0&&(t&(1<<(y+z-1)))!=0&&(t&(1<<(z-1)))!=0)
		return 1;
	return 0;	
}
ll fsp(ll x,int y){
	ll res=1;
	while(y){
		if(y&1)
			res=res*x%MOD;
		x=x*x%MOD;
		y>>=1;
	}
	return res;
}
int main(){
	SF("%d%d%d%d",&n,&x,&y,&z);
	dp[0][0]=1;
	ll ans=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<MAXM;j++)
			if(dp[i][j]!=0){
				for(int k=1;k<=10;k++){
					int j1=((j<<k)+(1<<(k-1)))%MAXM;
					if(check(j1)){
						ans+=(dp[i][j]*fsp(10,n-i-1))%MOD;
						ans%=MOD;
					}
					else{
						dp[i+1][j1]+=dp[i][j];
						dp[i+1][j1]%=MOD;
					}
				}
			}
	PF("%lld",ans);
}

Measured memory_bytes: 41088
from collections import deque
class shinajina():
    def push(A,que):
        if que[1]==0:
            A.appendleft(que[2])
        elif que[1]==1:
            A.append(que[2])
    def randomaccess(A,que):
        print(A[que[1]])
    def pop(A,que):
        if que[1]==0:
            A.popleft()
        elif que[1]==1:
            A.pop()
        
    
    


    
def main():
    q = int(input())
    A = deque()
    query = [list( map(int,input().split())) for i in range(q)]
    for que in query:
        if que[0]==0:
            shinajina.push(A,que)
        elif que[0]==1:
            shinajina.randomaccess(A,que)
        elif que[0]==2:
            shinajina.pop(A,que)


if __name__ == '__main__':
    main()



Measured memory_bytes: 69488
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main()
{
    fio;
    int n;
    cin>>n;
  vi v1(n);
    loop(i,0,n)
    {
        cin>>v1[i];
    }
    int ans = 0,k1 = INT_MAX;
    loop(i,0,n)
    {
       if(k1>v1[i])
       {
           k1 = v1[i];
           ans++;
       }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3888
S = input()

ans = 0 
ans_lis = [0]

for i in range(len(S)):
    if S[i] in "ACGT":
        ans = ans + 1 
    else:
        ans_lis.append(ans)
        ans = 0 

ans_lis.append(ans)
print(max(ans_lis))

Measured memory_bytes: 3064
n,T=map(int,input().split())
min_=1001
for _ in range(n):
	c,t=map(int,input().split())
	if t <= T:
		min_=min(min_,c)
	else:
		pass
if min_ == 1001:
	print('TLE')
else:
	print(min_)

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

int main(){
    int n, x;
    cin >> n >> x;
    int r = 0;
    int count = 1;
    vector<int> l(n);
    for(int i=0; i < n; i++){
        cin >> l.at(i);
    }
    for(int i = 0; i < n; i++){
        r += l.at(i);
        if(r <= x) count += 1;
        else break;
    }
    cout << count << endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
/*#define pmod(x,y) x=(x+y)%MOD;
#define qmod(x,y) x=(x*y)%MOD;*/
const ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
/*void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}*/
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll>x(n),y(m);
  for(i=0;i<n;i++)cin>>x[i];
  for(i=0;i<m;i++)cin>>y[i];
  ll z1,z2;
  buf=0;
  for(i=0;i<n/2;i++){
    buf=(buf+n-2*i-1)%MOD;
    l=(x[i+1]-x[i])%MOD;
    r=(x[n-i-1]-x[n-i-2])%MOD;
    z1=(buf*l)%MOD;
    res1=(z1+res1)%MOD;
    z2=(buf*r)%MOD;
    if(i!=n-i-2)res1=(z2+res1)%MOD;
  }
  buf=0;
  for(i=0;i<m/2;i++){
    buf=(m-2*i-1+buf)%MOD;
    l=(y[i+1]-y[i])%MOD;
    r=(y[m-i-1]-y[m-i-2])%MOD;
    buf2=(buf*l)%MOD;
    buf2=(buf2*res1)%MOD;
    res=(buf2+res)%MOD;
    buf2=(buf*r)%MOD;
    buf2=(buf2*res1)%MOD;
    if(i!=m-i-2)res=(res+buf2)%MOD;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1792
A, B, K = map(int,input().split())
if (B-A) // K < 2 or (B-A) / 2 == 0:
    L = []
    for i in range(A, B+1):
        L.append(str(i))
    print(' '.join(L))
else:
    L = []
    R = []
    for i in range(A, A+K):
        L.append(str(i))
    for j in range(B-K+1, B+1):
        R.append(str(j))
    ans = L + R
    print(' '.join(ans))


Measured memory_bytes: 3064
// ███▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓█
// ███▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███▓▓▓▓█▓╬╬╬▓█
// ███████▓█████▓▓╬╬╬╬╬╬╬╬▓███▓╬╬╬╬╬╬╬▓╬╬▓█
// ████▓▓▓▓╬╬▓█████╬╬╬╬╬╬███▓╬╬╬╬╬╬╬╬╬╬╬╬╬█
// ███▓▓▓▓╬╬╬╬╬╬▓██╬╬╬╬╬╬▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬╬╬╬▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓███████▓▓███▓╬╬╬╬╬╬▓███████▓╬╬╬╬▓█
// ████████████████▓█▓╬╬╬╬╬▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬█
// ███▓▓▓▓▓▓▓╬╬▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬▓▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓▓█▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓██▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// █████▓▓▓▓▓████▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓█▓▓▓▓██▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓▓███▓▓▓▓▓▓▓██▓╬╬╬╬╬╬╬╬╬╬╬╬█▓╬▓╬╬▓██
// █████▓███▓▓▓▓▓▓▓▓████▓▓╬╬╬╬╬╬╬█▓╬╬╬╬╬▓██
// █████▓▓█▓███▓▓▓████╬▓█▓▓╬╬╬▓▓█▓╬╬╬╬╬╬███
// ██████▓██▓███████▓╬╬╬▓▓╬▓▓██▓╬╬╬╬╬╬╬▓███
// ███████▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬████
// ███████▓▓██▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓████
// ████████▓▓▓█████▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█████
// █████████▓▓▓█▓▓▓▓▓███▓╬╬╬╬╬╬╬╬╬╬╬▓██████
// ██████████▓▓▓█▓▓▓╬▓██╬╬╬╬╬╬╬╬╬╬╬▓███████
// ███████████▓▓█▓▓▓▓███▓╬╬╬╬╬╬╬╬╬▓████████
// ██████████████▓▓▓███▓▓╬╬╬╬╬╬╬╬██████████
// ███████████████▓▓▓██▓▓╬╬╬╬╬╬▓███████████
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int M = 1e9 + 7;

string to_string(string s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define LOCAL
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

bool lucas(int m, int n){
    return (m&n)==n;
}

int main(){
	ios::sync_with_stdio(0),cin.tie(0);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int res=0;
	bool is_one=false;
	for(int i=0;i<s.size();i++){
        int num = s[i]-'1';
        if(num==1 && lucas(n-1, i)){
            res ^= 1;
        }
        if(num==1){
            is_one=true;
        }
//        debug(k);
//        k = k * p / q;
//        p--;
//        q++;
	}
	if(res){
        cout<<res<<"\n";
        return 0;
	}
    if(is_one){
        cout<<"0\n";
        return 0;
    }
    res=0;
//    k=1;
//    p=n;
//    q=1;
    for(int i=0;i<s.size();i++){
        int num = s[i]-'1';
        assert(num==0||num==2);
//        debug(k);
        if(num==2 && lucas(n-1, i)){
            res ^= 1;
        }
//        k = k * p / q;
//        p--;
//        q++;
	}
	if(res){
        cout<<"2\n";
	} else{
        cout<<"0\n";
	}
}


Measured memory_bytes: 1948
n = int(input())
X = [[] for _ in range(n)]
for i in range(n):
    x,l = list(map(int, input().split()))
    X[i] = [x-l,x+l]

X.sort(key = lambda x: x[1])
cnt = 1
mx = X[0][1]
for i in range(1,n):
    if mx <= X[i][0]:
        cnt += 1
        mx = X[i][1]
print(cnt)

Measured memory_bytes: 25504
n, k, q = map(int, input().split())

a = []
for i in range(q):
    a.append(int(input()))

point = [k] * n

for i in range(q):
    win = a[i - 1]
    point[win - 1] += 1

point = list(map(lambda x: x - q, point))

for i in range(n):
    if point[i] <= 0:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 13760
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N;
    cin >> N;
    int num=1000;
    while(num<N) num+=1000;
    cout << num-N << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
    
using namespace std;
    
int main(){
 int n,i;
 long long sum;
 cin >> n;
 int a[n];
 for (i=0;i<n;i++) {
   cin >> a[i];
 }
 sort(a, a+n);
 for (i=0;i<n;i++) {
  sum+=a[i];
 }
 cout << a[0] << " " << a[n-1]  << " " << sum << endl;
 return 0;
}



Measured memory_bytes: 3152
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+9;
int n,k; bool vst[N],in[N]; int tot,sl,a[N],cnt,loop[N];
void dfs(int u){
	tot++;
	vst[u]=1;
	int v=a[u];
	if(vst[v]) sl=v;
	else dfs(v);
}
signed main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	dfs(1);
	int u=sl;
	int find=0;
	while(1){
		if(u==sl&&find) break;
		find=1;
		loop[++cnt]=u;
		in[u]=1;
		u=a[u];
	}
	loop[0]=loop[cnt];
	if(k<=tot-cnt){
		int ans=1;
		for(int i=1;i<=k;i++) ans=a[ans];
		cout<<ans;
	}else{
		k++;
		cout<<loop[(k-(tot-cnt))%cnt];
	}
	return 0;
}

Measured memory_bytes: 7036