akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector < ll >
#define vvll vector < vll >
#define vld vector < ld >
#define pll pair < ll,ll > 
#define ppll pair < ll, pll>
#define pld pair < ld,ld > 
#define vpll vector < pll >
#define vpld vector < pld >
#define all(X) X.begin(),X.end()
#define endl "\n"
#define sz(x) ((ll)((x).size()))
vll emptyVector;
const ll MAX = 2e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll binaryExpo(ll x, ll n)
{
	if(n == 0)
		return 1;
	if(n % 2 == 0)
		return binaryExpo((x*x) % MOD, n/2);
	return (x*binaryExpo((x*x) % MOD, n/2)) % MOD;
}

/*-------------------------------------------		CODE STARTS FROM HERE		------------------------------------------*/

bool doesExist(int x, int y, int h, int w)
{
	if(x - 1 > 0 and x + 1 <= h and y - 1 > 0 and y + 1 <= w)
		return true;
	return false;
}

void solve(void)
{
	ll h, w, n;
	cin >> h >> w >> n;
	ll b[10] = {0};

	b[0] = (h - 2)*(w - 2);

	map < pll, bool > vis;
	map < pll, ll > nb;

	for(int i = 0; i < n; i++)
	{
		ll x, y;
		cin >> x >> y;
		if(vis[mp(x, y)])
			continue;
		
		vis[mp(x, y)] = true;

		for(int j = -1; j <= 1; j++)
		{
			for(int k = -1; k <= 1; k++)
			{
				if(doesExist(x + j, y + k, h, w))
				{
					b[nb[mp(x + j, y + k)]]--;
					nb[mp(x + j, y + k)]++;
					b[nb[mp(x + j, y + k)]]++;
				}
			}
		}
	}

	for(int i = 0; i < 10; i++)
		cout << b[i] << endl;



}


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

	// int t;
	// cin >> t;
	// while(t--)
	{
		solve();
	}
	




	return 0;
}

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

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim S As Integer = SumOfTheDigits(N)

        If N Mod S = 0 Then
            WriteLine("Yes")
        Else
            WriteLine("No")
        End If
    End Sub

    Function SumOfTheDigits(X As Integer) As Integer
        Dim result As Integer
        Do While X <> 0
            result += X Mod 10
            X \= 10
        Loop
        Return result
    End Function

    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: 19920
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

// return C(n,2)
ll comb2(ll n) {
    return n*(n-1)/2;
}
int main() {
    int n;
    cin >> n;
    vector<int> cnt(n);
    vector<ll> comb(n);
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
        --a[i];
        ++cnt[a[i]];
    }
    // ボールすべて使う場合の組み合わせの総和sum
    ll sum = 0;
    rep(i,n) {
        sum += comb2(cnt[i]);
    }
    rep(i,n) {
        // a[i]が書かれたボールをひとつ取り除くと，
        // cnt[a[i]]がcnt[a[i]]-1になる
        // 前者の組み合わせを除外したあと，後者の組み合わせを含める
        cout << sum-comb2(cnt[a[i]])+comb2(cnt[a[i]]-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iWid = int.Parse(sS[0]);                            // 幅
            int iAx1 = int.Parse(sS[1]);                            // Aの左端
            int iBx1 = int.Parse(sS[2]);                            // Bの左端

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iAx2 = iAx1 + iWid;                                 // Aの右端
            int iBx2 = iBx1 + iWid;                                 // Bの右端
            int iOut = 0;                                           // 移動量
            Boolean bLnk = false;                                   // 連結状態
            if (iAx1 <= iBx1 && iBx1 <= iAx2) { bLnk = true; }      // Aの範囲にBの左端がある場合は連結
            if (iAx1 <= iBx2 && iBx2 <= iAx2) { bLnk = true; }      // Aの範囲にBの右端がある場合は連結
            if (!bLnk)                                              // 連結していない場合
            {
                Boolean bRig = false;                               // BがAの右にあるフラグ
                if (iAx1 < iBx1) { bRig = true; }                   // BがAの右にある場合
                if (bRig) { iOut = iBx1 - iAx2; }                   // Bの左端をAの右端まで移動(BがAの右にある場合)
                else { iOut = iAx1 - iBx2; }                        // Bの右端をAの左端まで移動(BがAの左にある場合)
            }

            //出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

int main(){
    int n,k;
    
    cin>>n>>k;
    int h[n];
    for(int i=0; i<n; i++)cin>>h[i];
    sort(h, h+n);
    int minn=1000000000;
    for(int i=0; i<n-k+1; i++){minn = min(minn , h[i+k-1]-h[i]);}
    cout<<minn<<endl;


    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t N;
    cin >> N;
    vector<int64_t>vec(100001, 0);
    for (int64_t i=0; i<N; i++) {
        int64_t num;
        cin >> num;
        vec[num] += 1;
    }

    int64_t sum = 0;
    for (int64_t i=0; i<100001; i++) {
        sum += (vec[i] * i);
    }

    int64_t Q;
    cin >> Q;
    for (int64_t i=0; i<Q; i++) {
        int64_t B, C;
        cin >> B >> C;
        int64_t count = vec[B];
        vec[B] = 0;
        vec[C] += count;
        sum -= count * B;
        sum += count * C;
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3996
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<set>
#include<queue>

using namespace std;

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

const double EPS = 1e-9;
int main(){

	string rank[8] = {"AAA","AA","A","B","C","D","E","NA"};
	double time500[8] = {35.50,37.50,40.00,43.00,50.00,55.00,70.00,0};
	double time1000[8] = {71.00,77.00,83.00,89.00,105.00,116.00,148.00,0};

	double n,m;
	while(cin>>n>>m){
		
		int r,rr;
		for(r=0;r<7;r++){
			if(n-time500[r] < -EPS)break;
		}
		for(rr = 0;rr<7;rr++){
			if(m-time1000[rr] < -EPS)break;
		}

		cout<<rank[max(r,rr)]<<endl;

	}

	return 0;
}

Measured memory_bytes: 0
s = list(input())
li = []
n = len(s)
ans = 0
b = False
for i in range(n-1):
    if b:
        b = False
        continue
    if s[i] + s[i+1] == 'BC':
        li.append('D')
        b = True
    if s[i] == 'B' and s[i+1] != 'C':
        li.append('E')
    if s[i] == 'C':
        li.append('E')
    if s[i] == 'A':
        li.append('A')
cnt = 0
for i in range(len(li)):
    if li[i] == 'A':
        cnt += 1
    elif li[i] == 'E':
        cnt = 0
    else:
        ans += cnt
print(ans)

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

using namespace std;
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 Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
//const int INF = 1 << 30;
const ll INF = 1LL << 60;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

struct edge{ll to, cost; };
typedef pair<ll, ll> Pll;
struct graph {
	ll V;
	vector< vector<edge> > G;
	vector<ll> d;

	graph(ll n) {
		inite(n);
	}

	void inite(ll n) {
		V = n;
		G.resize(V);
		d.resize(V);
		for (int i = 0; i < V; i++) d[i] = INF;
	}

	void add_edge(ll s, ll t, ll cost) {
		edge e;
		e.to = t; e.cost = cost;
		G[s].push_back(e);
	}

	void dijkstra(ll s) {
		for (int i = 0; i < V; i++) d[i] = INF;
		d[s] = 0;

		priority_queue< P, vector<P>, greater<P> > que;
		que.push(P(0, s));
		while (!que.empty()) {
			P p = que.top(); que.pop();
			ll v = p.second;
			if (d[v] < p.first) continue;
			for (int i = 0; i < G[v].size(); i++) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(P(d[e.to], e.to));
				}
			}
		}
	}
};

int n, m, s, t;
int u[100010], v[100010];
int a[100010], b[100010];

int main(void){
	cin>>n>>m>>s>>t; s--; t--;

	graph ga(n), gb(n);

	for (int i = 0; i < m; i++) {
		int u, v, a, b; cin>>u>>v>>a>>b;
		u--; v--;
		ga.add_edge(u, v, a);
		ga.add_edge(v, u, a);
		gb.add_edge(u, v, b);
		gb.add_edge(v, u, b);
	}

	ga.dijkstra(s);
	gb.dijkstra(t);

	vector<ll> ans(n + 1, INF);
	for (int i = n - 1; i >= 0 ; i--) {
		ans[i] = min(ans[i + 1], ga.d[i] + gb.d[i]);
	}

	for (int i = 0; i < n; i++) {
		cout<< (ll)1e15 - ans[i] <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 19000
#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 all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  string s;
  cin >> s;
  ll ans = 0;
  rep(i,s.size()){
    ll tmp = s[i] - '0';
    ans += tmp;
  }
  if(ans % 9 == 0)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3708
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.util.function.DoubleToLongFunction;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		System.out.println((sc.nextInt() + sc.nextInt()) * sc.nextInt() / 2);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

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

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

result = 0
for i, x in enumerate(A):
    result += B[x-1]
    if i == N-1:
        break
    if x+1 == A[i+1]:
        result += C[x-1]
        
print(result)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    String[] abc = line.split(" ");
    int a = Integer.parseInt(abc[0]);
    int b = Integer.parseInt(abc[1]);
    int d = a / b;
    int r = a % b;
    double a1 = (double)a;
    double b1 = (double)b;
    double f =a1 / b1;
    System.out.println(d + " " + r + " " + String.format("%.5f", f));
  }
}


Measured memory_bytes: 26384
#include <iostream>
#include <queue>
using namespace std;
#define MAX_N 400
#define P pair<int, int>
bool color[MAX_N][MAX_N];
bool used[MAX_N][MAX_N];
int H,W;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

bool isin(int i, int j) {
    return i>=0 && i<H && j>=0 && j<W;
}

bool path(int i, int j, int d) {
    int nx = i + dx[d];
    int ny = j + dy[d];
    return (color[i][j] != color[nx][ny]);
}

long long solve() {
    long long ans = 0;
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            used[i][j] = false;
        }
    }
    queue<P> q;
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            if(used[i][j]) continue;
            long long b=0, w=0;
            used[i][j] = true;
            if(color[i][j]) ++b;
            else ++w;
            q.push(P(i,j));
            while(!q.empty()) {
                P cur = q.front(); q.pop();
                for(int d=0; d<4; ++d) {
                    int nx = cur.first + dx[d];
                    int ny = cur.second + dy[d];
                    if(isin(nx,ny) && path(cur.first,cur.second,d) && !used[nx][ny]) {
                        used[nx][ny] = true;
                        if(color[nx][ny]) ++b;
                        else ++w;
                        q.push(P(nx,ny));
                    }
                }
            }
            ans += b * w;
        }
    }
    return ans;
}

int main() {
    cin >> H >> W;
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            char c; cin >> c;
            color[i][j] = (c == '#');
        }
    }
    long long ans = solve();
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

#define pb push_back

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define MOD(x, y) (((y) + (x) % (y)) % (y))

int N;
int F[101][6][3];
int P[101][11];

int main(int argc, char* argv[])
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= 5; j++) {
			int a, b;
			scanf("%d%d", &a, &b);
			F[i][j][1] = a;
			F[i][j][2] = b;
		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= 10; j++) {
			scanf("%d", &P[i][j]);
		}
	}

	int m = 0x80000000;
	for (int i = 1; i < (1 << 10); i++) {
		int s = 0;
		for (int k = 1; k <= N; k++) {
			int t = 0;
			for (int j = 0; j < 10; j++) {
				if (i & (1 << j)) {
					t += F[k][j / 2 + 1][j % 2 + 1];
				}
			}
			s += P[k][t];
		}
		m = max(m, s);
	}
	printf("%d\n", m);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define ull unsigned long long
    #define ll long long
    #define pi  acos(-1)
    const int w=5e5+5;
    const ll mod=998244353;
    int a[w];
    int main()
    {
        int i,j;
        int n,m;
        cin>>n>>m;
        for(i=1;i<=m;i++)
            scanf("%d",&a[i]);
        ll ans=1e18;
        for(i=1;i<=m;i++)
        {
            int pos=m+i-1;
            if(pos>m)
                pos-=m;
            ll u=a[pos]-a[i];
            if(u<0)
                u+=n;
            ans=min(ans,u);
        }
        cout<<ans<<endl;
        return 0;
    }

Measured memory_bytes: 1024
$|=1;
$N = <STDIN>;
chomp $N;
$K = <STDIN>;
chomp $K;

$V=1;
for($i=1;$i<=$N;$i++){
	if($V+$K<$V*2) {
		$V=$V+$K;
	} else {
		$V=$V*2;
	}
}
print "$V\n";


Measured memory_bytes: 384
use proconio::input;

fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }
    let PI = std::f64::consts::PI;
    let lx = a * (2f64 * PI / 60f64 * m).cos();
    let ly = a * (2f64 * PI / 60f64 * m).sin();
    let sx = b * (2f64 * PI / 720f64 * (h * 60f64 + m)).cos();
    let sy = b * (2f64 * PI / 720f64 * (h * 60f64 + m)).sin();

    let res = ((lx - sx) * (lx - sx) + (ly - sy) * (ly - sy)).sqrt();

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


Measured memory_bytes: 2960
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll x;cin>>x;
	ll ans=0;
	ans += 1000*(x/500);
	x = x%500;
	ans += 5*(x/5);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    a = list(map(int, input().split()))

    dp = [0 for i in range(N)]

    for i in range(N-1, -1, -1):
        dp[i] = a[i]
        prev = dp[i]
        for j in range(i+1, N):
            right = a[i] - dp[j]
            left = a[j] - prev
            if right > left:
                dp[j] = right
                prev = right
            else:
                dp[j] = left
                prev = left
    print(dp[-1])


main()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
using namespace std;
signed main(){
    int n;
    cin >> n;
    int a = sqrt(n);
    cout << a* a << endl;
    return 0;
}

Measured memory_bytes: 256
import math
import itertools
def distance(xi,yi,xj,yj):
    return(math.sqrt((xi-xj)**2+(yi-yj)**2))
n = int(input())
xy = []
for i in range(n):
    li = list(map(int,input().split()))
    xy.append(li)
dis_li = []
count = 0
for it in itertools.permutations(xy):
    dis = 0
    for i in range(len(it)-1):
        dis += distance(it[i][0],it[i][1],it[i+1][0],it[i+1][1])
    dis_li.append(dis)
    count += 1
print(sum(dis_li)/count)

Measured memory_bytes: 4404
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

int main() {
  ll n, m;
  cin >> n >> m;

  ll ans = n * (n - 1) / 2;
  ans += m * (m - 1) / 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())

if (((N - 1) * (N - 2)) // 2) < K:
	print(-1)
	exit()

result = []
for n in range(1, N):
	result += [(1, n + 1)]

l, r = 2, 3
for k in range((((N - 1) * (N - 2)) // 2) - K):
	result += [(l, r)]
	if r == N:
		l += 1
		r = l + 1
	else:
		r += 1

print(len(result))
for v in result:
	print(*v)


Measured memory_bytes: 3992
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        string s;cin>>s;
        int n=s.size();
        vi r,l;
        rep0(n) if(s[i]=='L') l.pb(i); else r.pb(-i);
        //FORE(it,l) cout<<*it<<" ";cout<<endl;
        //FORE(it,r) cout<<*it<<" ";
        sort(all(r));
        vi ans(n+1,0);
        rep0(n){
            if(s[i]=='R'){
                int k=upper_bound(all(l),i)-l.begin();
                //cout<<k<<" ";
                if((l[k]-i)%2) ans[l[k]-1]++;
                else ans[l[k]]++;
            }
            else{
                int k=upper_bound(all(r),-i)-r.begin();
                if((-r[k]-i)%2) ans[-r[k]+1]++;
                else ans[-r[k]]++;
            }
        }
         rep0(n) cout<<ans[i]<<" ";


         r0
     }
    signed main()
    {   //inputoutput
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 2372
#include <bits/stdc++.h>
using ll=long long;
using ld=long double;
using namespace std;
int main(){
  ll n,cnt=0;
  cin>>n;
  ll k=(ll)(ceil((ld)n/11));
  if(k*11-n>=5)cout<<k*2-1;
  else cout<<k*2;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

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

int n, m;
string fi[210];
bool seen[210][210];

int res = 0;
void rec(int x, int y) {
	seen[x][y] = true;
	for (int i = 0; i < 4; ++i) {
		int nx = x + dx[i], ny = y + dy[i];
		if (nx < 0 || nx >= n || ny < 0 || ny >= m) continue;
		if (seen[nx][ny]) continue;
		if (fi[nx][ny] != fi[x][y]) continue;
		rec(nx, ny);
	}
}

int main() {
	while (cin >> n >> m) {
		if (n == 0) break;
		for (int i = 0; i < n; ++i) cin >> fi[i];
		res = 0; memset(seen, 0, sizeof(seen));
		for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
			if (seen[i][j]) continue;
			rec(i, j);
			++res;
		}
		cout << res << endl;
	}
    return 0;
}


Measured memory_bytes: 2208
#include <cstdio>

int
main(void)
{
  int n, m;
  
  std::scanf("%d %d", &n, &m);

  int m_a[n][m], v_b[m];
  long v_c[n];
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      std::scanf("%d", &m_a[i][j]);
    }
  }

  for (int i = 0; i < m; i++) {
    std::scanf("%d", &v_b[i]);
  }

  for (int i = 0; i < n; i++) {
    v_c[i] = 0;
    for (int j = 0; j < m; j++) {
      v_c[i] += m_a[i][j] * v_b[j];
    }
  }

  for (int i = 0; i < n; i++) {
    std::printf("%ld\n", v_c[i]);
  }
  
  return 0;
}



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

int main(){

  int n;
  string s;
  cin >> n >> s;

  if(s.length()>n){
    for(int i=0;i<n;i++){
      cout << s[i];
    }
    cout << "..." << endl;
  }else{
    cout << s << endl;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

using namespace std;

constexpr int INF = 1000000000;/* 1e+9a */
constexpr int MODULO = 1000000007;

typedef int64_t ll;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int onePoint;
    for (int i = 0; i < N; ++i) {
        int tmp;
        std::cin >> tmp;
        if(tmp == 1){
            onePoint = i;
        }
    }
    onePoint = 1;
    int ans = 0;
    while(N - onePoint > 0){
        onePoint += K-1;
        ans++;
    }
    cout << ans << endl;

}


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

int main(){
    int n;
    int i = 0;
    int sum = 0;
    int a;
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> a;
        sum += a;
    }
    
    int ans = sum - n;
    cout << ans << endl;
}


Measured memory_bytes: 256
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#dp[i][j]: iまでからj枚えらんで和がkになるのは何通り
def main():
	s = input()
	ans = 0
	if(len(s)==1): print(int(s));exit()
	for i in range(0,2**(len(s)-1)):
		temp = []
		ix2 = base_10_to_n(i,2)
		for i in range(len(s)-len(ix2)-1):
			ix2 = '0' + ix2
		tmp = s[0]
		for j in range(len(ix2)):
			if(ix2[j]=='1'):
				temp.append(tmp)
				tmp = s[j+1]
			else:
				tmp = tmp + s[j+1]
		temp.append(tmp)
		for i in temp:
			ans+=int(i)
	print(ans)


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Measured memory_bytes: 68332
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n, r; cin >> n >> r;
    cout << r + 100 * max((10 - n), 0) << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(isize);
    let mut xl = get!(isize, isize; n);

    let mut robots = xl.into_iter().map(|(x,l)| (x-l,x+l)).collect::<Vec<_>>();
    robots.sort_by_key(|e| e.1);

    let mut sum = 0;
    let mut tright = std::isize::MIN;
    for (left,right) in robots {
        if tright > left {
            sum += 1;
        } else {
            tright = right;
        }
    }
    println!("{}", n-sum);
}


Measured memory_bytes: 12540
# include <stdio.h>

int main(void)
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a<=b){
   if(b<=c){
      printf("%d %d %d\n",a,b,c);
   }else if(b>c){
      if(a<=c){
         printf("%d %d %d\n",a,c,b);
      }else if(a>c){
         printf("%d %d %d\n",c,a,b);
      }
   }
}else if(a>b){
   if(a<=c){
      printf("%d %d %d\n",b,a,c);
   }else if(a>c){
      if(b<=c){
         printf("%d %d %d\n",b,c,a);
      }else if(b>c){
         printf("%d %d %d\n",c,b,a);
      }
   }
}
  return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>
#include<string.h>
#define NUM 10
int main(){
   int x,x1,x2,i;
   int cnt=0;
   scanf("%d",&x);
   scanf("%d %d",&x1,&x2);
   for(i=x1;i<=x2;i++){
      if(i%x==0){
         cnt++;
      }
   }
   if(cnt>0){
      printf("OK");
   }else{
      printf("NG");
   }
   
   return 0;
}


Measured memory_bytes: 1732
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fst first
#define snd second
using ll = long long;
using I = pair<int, int>;
const int INF = 100010;

int main() {
  int N;
  while (cin >> N) {
    vector<int> dp(N + 1);
    for (int i = 0; i <= N; i++) dp[i] = i;
    for (int i = 0; i < N; i++) {
      dp[i + 1] = min(dp[i + 1], dp[i] + 1);
      for (int c = 6; i + c <= N; c *= 6) dp[i + c] = min(dp[i + c], dp[i] + 1);
      for (int c = 9; i + c <= N; c *= 9) dp[i + c] = min(dp[i + c], dp[i] + 1);
    }
    cout << dp[N] << endl;
  }
  return 0;
}


Measured memory_bytes: 640
from collections import Counter
s = input()
k = int(input())
n = len(s)
bb = Counter(s)
b = list(bb)
b.sort()
a = set([])

for l in range(k):
    for i in range(n):
        if s[i] == b[l]:
            for j in range(5):
                if i + j > n:
                    break
                a.add(s[i:i+1+j])
    if len(a) >= k:
        break
        
b = list(a)
b.sort()
print(b[k-1])

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

constexpr long long int M = 1000000007;

template<int N>
struct Fact{
  long long int val[N];
  long long int v2[N];
  constexpr Fact() : val(), v2() {
    val[0] = 1;
    for(int i = 1; i < N; ++i)val[i] = val[i - 1] * i % M;
    for(int i = 1; i < N; ++i)v2[i] = val[i - 1] * val[i] % M;
  }
};

template<int N, long long F>
struct IFact{
  long long int val[N];
  constexpr IFact() : val() {
    val[N - 1] = F;
    for(int i = N - 1; i > 0; --i)val[i - 1] = val[i] * i % M;
  }
};

long long int N, ans;
constexpr auto fact = Fact<1000001>();
constexpr auto ifact = IFact<1000001, 397802501>();

int main(){
    std::ios::sync_with_stdio(false);
    scanf("%lld", &N);
    for(int i = (N + 1) / 2; i < N - 1; ++i){
        ans += fact.v2[i] * ifact.val[i * 2 - N] % M;
    }
    ans = fact.val[N] - fact.val[N - 1] - ans;
    ans %= M;
    printf("%lld\n",(ans > 0 ? ans : M + ans));
    //cout << (ans > 0 ? ans : M + ans) << endl;
    return 0;
}


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

int main()
{
	int N,T,A;
	cin>>N>>T>>A;
	float Ht[N];
	for(int i=0;i<N;i++)
	{
		cin>>Ht[i];
	}
	int SolutionIndex=0;
	float MinDiff=INT_MAX;
	for(int i=0;i<N;i++)
	{
		Ht[i]=abs(A-(T-Ht[i]*0.006));
		if(MinDiff>Ht[i])
		{
			MinDiff=Ht[i];
			SolutionIndex=i;
		}
	}
	cout<<SolutionIndex+1<<endl;
}

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

#define rep(i,a,b)                for(ll i=a;i<b;i++)
#define re(i,b)                for(ll i=0;i<b;i++)
#define repr(i,n)                for(ll i=n-1;i>=0;i--)
#define ll long long
#define ld long double
#define pll std::pair<ll, ll> 
#define ppll std::pair<pll, ll>
#define vll std::vector<ll> 
#define vpll std::vector<pll> 
#define vppll std::vector<ppll> 
#define mll std::unordered_map<ll, ll> 
#define mpll std::unordered_map<pll, ll>
#define mppll std::unordered_map<ppll, ll>
#define sll std::set<ll>
#define ff first
#define ss second
#define msll std::multiset<ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define srt(x) sort(all(x))
#define rsrt(x) sort(allr(x))
#define eb emplace_back
#define pb push_back
#define s(yy) ll yy;cin>>yy
#define len length()
#define sz size()
const ll mod = 1e9 + 7;
const ll INF = 0x7FFFFFFFFFFFFFFF>>1;

/*#################################################### 
#                                                    #
#                     @author                        #
#                  Parth Lathiya                     #
#      https://www.cse.iitb.ac.in/~parthiitb/        #
#                                                    #
####################################################*/


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef PARTH_LATHIYA_HOME

        freopen("A_in.txt","r",stdin);
    
        ll ttt,bkkk;
        cin>>ttt;
        bkkk=ttt;
        while(ttt--) {
            cout<<"Testcase - "<<bkkk-ttt<<"\n";
    #endif

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

    s(aa);
    s(b);
    char a[100][100];

    re(i,50)
        re(j,100)
            a[i][j]='#';
    rep(i,50,100)
        re(j,100)
            a[i][j]='.';
    int f=0;
    for(ll i=0;i<49;i+=2){
        for(ll j=0;j<100;j+=2){
            if(aa==1){
                f=1;break;
            }
            a[i][j]='.';
            aa--;
            
        }
        if(f)
            break;
    }
    f=0;
    for(ll i=51;i<100;i+=2){
        for(ll j=0;j<100;j+=2){
            if(b==1){
                f=1;break;
            }
            a[i][j]='#';
            b--;
            // if(b==1){
            //     f=1;break;
            // }
        }
        if(f)
            break;
    }
    cout<<100<<" "<<100<<endl;
    re(i,100){
        re(j,100)
            cout<<a[i][j];
        cout<<endl;
    }

//--------------------------------------------------------------------------------------
    
    #ifdef PARTH_LATHIYA_HOME
        cout<<"\n"; }
    #endif

    return 0;
}

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

int main()
{
    int n, x;
    vector<int> m;

    cin >> n >> x;

    int tmp;
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        m.push_back(tmp);
    }

    sort(m.begin(), m.end());

    for (auto ite = m.begin(); ite != m.end(); ite++)
    {
        x -= *ite;
    }

    int ans = n + x / m[0];

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


Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
  a.append(int(input()))

b = sorted(a)
maxnum = b[-1]
nextmaxnum = b[-2]

if maxnum == nextmaxnum:
  for i in range(n):
    print(maxnum)
else:
  for i in range(n):
    if a[i] == maxnum:
      print(nextmaxnum)
    else:
      print(maxnum)

Measured memory_bytes: 14112
use std::io::prelude::*;
use std::str::FromStr;
pub struct Scanner<R: Read>(R);
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self(reader)
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();
        unsafe { std::str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = std::io::BufWriter::new(stdout.lock());
    solve(&mut sc, &mut out);
    out.flush().ok().unwrap();
}
fn solve(sc: &mut Scanner<std::io::StdinLock>, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let N: usize = sc.read();
    let mut A = Vec::new();
    for _ in 0..N {
        let tup: (i32, i32, i32) = (sc.read(), sc.read(), sc.read());
        A.push(tup);
    }

    let mut ct = 0;
    let mut cx = 0;
    let mut cy = 0;
    for &(t, x, y) in A.iter() {
        let dist = (x - cx).abs() + (y - cy).abs();
        if dist <= t - ct && ((t - ct - dist) & 1) == 0 {
            ct = t;
            cx = x;
            cy = y;
        } else {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int k=scan.nextInt();
		scan.nextLine();
		String s=scan.nextLine();
		String t="";
		for(int i=0;i<n;i++)
		{
			if(i==k-1)
			{
				t+=s.toLowerCase().charAt(i);
			}
			else
			{
				t+=s.charAt(i);
			}
		}
		System.out.println(t);
	}

}


Measured memory_bytes: 27068
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.14159265358979323846;

long long f(long long b, long long n) {
    if (n < b) {
        return n;
    }
    return f(b, n / b) + n % b;
}

set<long long> divisors(long long n) {
    set<long long> div;
    for (long long d = 1; d * d <= n; ++d) {
        if (n % d == 0) {
            div.insert(d);
            div.insert(n / d);
        }
    }
    return div;
}

void solve(long long n, long long s) {
    if (n < s) {
        cout << -1 << '\n';
        return;
    }
    if (n == s) {
        cout << n + 1 << '\n';
        return;
    }
    for (long long b = 2; b <= sqrt(n); ++b) {
        long long k = f(b, n);
        if (k == s) {
            cout << b << '\n';
            return;
        }
    }
    long long t = n - s;
    for (long long b : divisors(t)) {
        if (f(b + 1, n) == s) {
            cout << b + 1 << '\n';
            return;
        }
    }
    cout << -1 << '\n';
    return;
}

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

    long long n, s;
    cin >> n >> s;

    solve(n, s);

    return 0;
}


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

#define endl '\n'
#define int long long


const int N = 3005;
int cache[N][N][2];
int a[N], n;


int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin >> n;
	for(auto &it : a) cin >> it;

	for(int i = 0; i < n; i ++) {
		cache[i][i][0] = a[i];
		cache[i][i][1] = -a[i];
	}

	for(int len = 2; len <= n; len ++) {
		for(int i = 0; i + len <= n; i ++) {
			int j = i + len - 1;
			cache[i][j][0] = max(cache[i+1][j][1] + a[i], cache[i][j-1][1] + a[j]);
			cache[i][j][1] = min(cache[i+1][j][0] - a[i], cache[i][j-1][0] - a[j]);
		}
	}

	cout << cache[0][n-1][0] << endl;

	return 0;
}

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

char f[102][102];
char cnt_c[1];

void DFS(int y,int x){
  if(f[y][x]=='.'||f[y][x]==0||f[y][x]!=cnt_c[0])return;
  if(f[y][x]==cnt_c[0]){
    f[y][x]='.';
  }
  DFS(y+1,x);
  DFS(y-1,x);
  DFS(y,x+1);
  DFS(y,x-1);
}

int main(){
  int H,W;
  while(cin>>H>>W){
     if(H==0&&W==0)return 0;
      for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin>>f[i][j];
        }
      }
      int cnt=0;
      for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
          if(f[i][j]=='@'||f[i][j]=='#'||f[i][j]=='*'){
            cnt_c[0]=f[i][j];
            DFS(i,j);
            cnt++;
          }
        }
      }
      cout<<cnt<<endl;
    }
}



Measured memory_bytes: 3500
#include <cstdio>
#include <algorithm>

int main()
{
  int a[3];
  scanf("%d%d%d", a, a + 1, a + 2);
  std::sort(a, a + 3);
  int c = a[2] - a[0];
  int d = a[2] - a[1];
  if (((c ^ d) & 1) == 0)
  {
    printf("%d\n", (c & 1) + c / 2 + d / 2);
  }
  else
  {
    printf("%d\n", 1 + (c + 1) / 2 + (d + 1) / 2);
  }
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

//mt19937 random(566);
//uniform_int_distribution<ll> distr;
//ll rnd(ll a, ll b) {return a + distr(random) % (b - a + 1);}

const int N = 2e5 + 1;
const ll MOD = 1e9 + 7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> k >> n;
    vi a(n);
    forn(i, n) cin >> a[i];
    vi b(n);
    forn(i, n - 1) b[i] = a[i + 1] - a[i];
    b[n - 1] = k - a[n - 1] + a[0];
    int sum = 0;
    int ans = 2e9;
    forn(i, n) sum += b[i];
    forn(i, n) ans = min(ans, sum - b[i]);
    cout << ans << "\n";
    return 0;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,x) for(ll i=0;i<x;i++)
#define INF 1e18
typedef long long ll;
using namespace std;
#define MOD 1000000007


int main(){
  vector<vector<int>> A(3,vector<int>(3,0)),ans(3,vector<int>(3,0));
  REP(i,3){
    REP(j,3)cin>>A[i][j];
  }
  int N;cin>>N;
  REP(k,N){
    int b;cin>>b;
    REP(i,3){
      REP(j,3){
        if(A[i][j]==b)ans[i][j]=1;
      }
  }
  }
  REP(i,3){
    int a=0;
    REP(j,3){
      a+=ans[i][j];
    }
    //cout<<a<<endl;
    if(a==3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  REP(i,3){
    int a=0;
    REP(j,3){
      a+=ans[j][i];
    }
    //cout<<a<<endl;
    if(a==3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if(ans[0][0]+ans[1][1]+ans[2][2]==3||ans[2][0]+ans[1][1]+ans[0][2]==3){
    cout<<"Yes"<<endl;
      return 0;
  }
  cout<<"No"<<endl;


  

}


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

int countFactors(int n) {
	int c = 0;
	while (n % 2 == 0) {
		++c;
		n /= 2;
	}
	return c;
}

int main() {
	int n;
	cin >> n;
	int input;
	cin >> input;
	int min = countFactors(input);
	for (int i = 0; i < n - 1; ++i) {
		cin >> input;
		int f = countFactors(input);
		if (f < min) 
			min = f;
	}
	cout << min;
	return 0;
}

Measured memory_bytes: 256