akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
using namespace std;
#define L 200005

char s[L],t[L];
int len,last[30];
int lasts[L],lastt[L];
bool flag=true;

int main() {
	scanf("%s %s",s,t);
	len=strlen(s);
	for(int i=0;i<len;i++) {
		int j=s[i]-'a';
		lasts[i]=last[j];
		last[j]=i;
	}
	memset(last,0,sizeof(last));
	for(int i=0;i<len;i++) {
		int j=t[i]-'a';
		lastt[i]=last[j];
		last[j]=i;
	}
	for(int i=0;i<len;i++)
		if(lasts[i]!=lastt[i]) {
			printf("No\n");
			return 0;
		}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


int main() {
  int a;
  ll k,x,y,m,memo=1,sx=1,sy=1,gx,gy;
  string ka,ss;
  ll n,ans=0;
  cin>>n;
  int num[n];
  vector<int> count(n+1,0);
  map<int,ll>mp;
  rep(i,n){
    cin>>x;
    num[i]=x;
    count[x]+=1;
  }
  rep(i,n){
    //cout<<num[i]<<count[i]<<endl;
    k=count[i+1];
    if(k!=0){ans+=ll(k*(k-1)/2);
    mp[i+1]=ll((k*(k-1)/2)-(k-1)*(k-2)/2);}
  }
  rep(i,n){y=mp[num[i]];m=ans-y;
    cout<<m<<endl;}

  vector<string> field(y);
  
  
  //cout<<dp[x-1][y-1]<<endl;

  //vector<vector<bool>> sinsetsu(15,vector<bool>(14)),usotsuki(15,vector<bool>(14));
  //vector<vector<int>> sss(15,vector<int>(14))
  //vector<vector<int>> sss(h,vector<int>(w));
  //vector<int> a(k),b(k);
  //char x;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,h=0;
    cin>>x;
    if(x<5)
    {
        cout<<h<<endl;
    }
    else{
        h=h+(x/500)*1000;
        x=x%500;
        h=h+(x/5)*5;
        cout<<h<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a%b==0) {
		System.out.println(a%b);
	}
		else {
			System.out.println(1);
		}
	}
}


Measured memory_bytes: 23508
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         char[] arr = infile.readLine().toCharArray();
         long[] cnt = new long[3];
         for(char c: arr)
         {
            int dex = 0;
            if(c == 'G')
               dex=1;
            else if(c == 'B')
               dex=2;
            cnt[dex]++;
         }
         long res = cnt[0]*cnt[1]*cnt[2];
         for(int d=1; d <= N; d++)
         {
            int temp = 0;
            for(int i=d; i < N-d; i++)
               if(arr[i] != arr[i-d] && arr[i] != arr[i+d] && arr[i+d] != arr[i-d])
                  temp++;
            res-=temp;
         }
         System.out.println(res);
      }
   }

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

int main(){
    int n,b,f,r,v;
    int arr[4][3][10];
    scanf("%d",&n);
    for(int i = 0 ;i < 4; i++){
        for(int j=0;j<3;j++){
            for(int k = 0; k < 10; k++){
                arr[i][j][k]=0;
            }
        }
    }
    for(int i = 0 ;i < n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        arr[b-1][f-1][r-1]+=v;
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k++){
                cout << " " << arr[i][j][k];
            }
            if(j != 2 || (j == 2 && i == 3)){
                cout << endl;
            }else if(i != 3){
                cout << "\n####################\n" ;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3140
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n,k;
    cin>>n>>k;
    if(n==1)    cout<<k<<endl;
    else{
        i64 prod = k;
        n--;
        while(n--){
            prod *= (k - 1);
        }
        cout<<prod<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)
#define MIN(a, b) ((a) < (b)) ? (a) : (b)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 29;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


int main()
{
	int N;
	cin >> N;
	vi X(N);
	rep(i, N) cin >> X[i];
	vi XX = X;
	sort(all(XX));

	rep(i, N) {
		if (X[i] <= XX[(N + 1) / 2 - 1]) cout << XX[N / 2] << endl;
		else cout << XX[N / 2 - 1] << endl;
	}


	return 0;
}

Measured memory_bytes: 3712
s = int(input())
rec = set()


def f(x):
    if x % 2 == 0:
        return x//2
    else:
        return 3*x + 1


c = 1
while True:
    if s in rec:
        print(c)
        exit()
    rec.add(s)
    s = f(s)
    c += 1


Measured memory_bytes: 2940
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    use Ordering::*;
    let n = get();
    let a: Vec<i64> = (0 .. n).map(|_| get()).collect();
    let mut pos = 0;
    let mut cnt = 0;
    while pos < n {
        cnt += 1;
        let mut cp = Equal;
        while pos < n - 1 {
            let res = a[pos].cmp(&a[pos + 1]);
            if cp != Equal && res != Equal && cp != res {
                break;
            }
            if res != Equal {
                cp = res;
            }
            pos += 1;
        }
        pos += 1;
    }
    println!("{}", cnt);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
/* original submission: 
   https://atcoder.jp/contests/abc129/submissions/5855637 */
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include <cstring>

#define MOD 1000000007

using namespace std;

int64_t pow(int64_t x, int64_t y) {
  if (y == 0) {
    return 1;
  } else if (y % 2) {
    return pow(x, y - 1) * x % MOD;
  } else {
    int64_t tmp = pow(x, y / 2);
    return tmp * tmp % MOD;
  }
}

int64_t solve(const char *s, int64_t len) {
  int64_t ans0 = pow(3, len - 1);
  int i;
  for(i = 1; i < len; i++){
    if(s[i] == '1') break;
  }
  int64_t ans1 = 2;
  if(i < len) {
    ans1 *= solve(&s[i], len - i);
  }
  return (ans1 + ans0) % 1'000'000'007;
}

int main(int argc, char *argv[]) {
  string s;
  cin >> s;
  cout << solve(s.c_str(), s.size()) << endl;
  return 0;
}


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

int main() {
    int n; cin >> n;
    map<string,int> t;
    rep(i,n) {
        string s; cin >> s;
        t.emplace(s,0);
    }
    cout << t.size() << "\n";
}

Measured memory_bytes: 19208
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll h,w;
  cin >>h>>w;
  ll n;
  cin >>n;
  ll a[n];
  for(ll i=0;i<n;i++) cin >>a[i];
  ll k=0,l=0;
  vector <ll> v[h];
  for(ll i=0;i<n;i++){
    for(ll j=0;j<a[i];j++){
      v[l].push_back(i+1);
      k++;
      if(k==w){
        l++;
        k=0;
      }
    }
  }
  for(ll i=0;i<h;i++){
    if(i%2==0){
      for(ll j=0;j<w-1;j++){
          cout <<v[i][j]<<" ";
      }
      cout <<v[i][w-1]<<endl;
    }
    else{
      for(ll j=w-1;j>=1;j--){
          cout <<v[i][j]<<" ";
      }
      cout <<v[i][0]<<endl;
    }
  }
}


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

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int inf = 1000000000; // 10^9

int main(){
   char n[20];scanf("%s",n);
   int h1=0,h2=0;

   for(int i =  strlen(n)-1,j = 1;i >= 0;i--,j*=10){
      h1 += (int)n[i]-48;
      h2 += ((int)n[i]-48)*j;
   }
   //printf("%d %d\n",h1,h2);
   if(h2%h1==0)printf("Yes");
   else printf("No");

}


Measured memory_bytes: 128
# AOJ 1167 - ポロック予想
# 配るDP でいってみよ～

import sys


def main():
    tetra_nums = [i * (i + 1) * (i + 2) // 6 for i in range(1, 181)]
    N = 10 ** 6

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

    for n in range(N):
        for tetra_num in tetra_nums:
            next_n = n + tetra_num

            if next_n < N:
                next_dp = dp[n] + 1
                if next_dp < dp[next_n]:
                    dp[next_n] = next_dp

                if tetra_num & 1:
                    next_dp = dp_odd[n] + 1
                    if next_dp < dp_odd[next_n]:
                        dp_odd[next_n] = next_dp

    while True:
        num = int(sys.stdin.readline())
        if num == 0:
            break
        print(dp[num], dp_odd[num])


if __name__ == '__main__':
    main()




Measured memory_bytes: 84632
dnum = gets.to_i
output = []
for i in 0..dnum-1
    n,k = gets.split(" ").map(&:to_i)
    x = []
    x << gets.split(" ").map(&:to_i)
    xd = []
    for i in 0..n-2
        xd << x[0][i+1] - x[0][i]
    end
    xd.sort!
    sum = 0
    for i in 0..xd.length-k
        sum += xd[i]
    end
    output << sum
end
for i in 0..output.length-1
    print("#{output[i]}\n")
end

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

int main()
{
    int n,x,t;
    scanf("%d %d %d",&n,&x,&t);
    if(n%x==0)
        printf("%d",t*n/x);
    else
        printf("%d",(n/x+1)*t);
    return 0;
}


Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
const int MAX=100000,NIL=-1;
int n,color[MAX];
vector<int> G[MAX];
void dfs(int r,int c){
    stack<int> S;
    S.push(r);
    color[r]=c;
    while(!S.empty()){
        int u=S.top(); S.pop();
        for(int i=0;i<G[u].size();i++){
            int v=G[u][i];
            if(color[v]==NIL){
                color[v]=c;
                S.push(v);
            }
        }
    }
}
void assign(){
    int id=1;
    for(int i=0;i<n;i++){
        color[i]=NIL;
    }
    for(int u=0;u<n;u++){
        if(color[u]==NIL) dfs(u,id++);
    }
}
int main(void){
    int s,t,m,q;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assign();
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> s >> t;
        if(color[s]==color[t]) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 8932
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		long[] x = new long[100010];
		for(int i = 0 ; i < n ; i++) {
			x[a[i]] = 0;
		}
		for(int i = 0 ; i < n ; i++) {
			x[a[i]] += b[i];
		}
		for(int i = 1 ; i <= 100000 ; i++) {
			if(x[i] >= 0) {
				k -= x[i];
				if(k <= 0) {
					System.out.println(i);
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 65244
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

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

using Graph = vector<vector<int> >;

void dfs(Graph &G, vector<ll>&ans, int p){
    for(auto next_v : G.at(p)){
        if(next_v>p){
            ans.at(next_v)+=ans.at(p);
            // dfs(G,ans,next_v);
        }
    }
}

int main() {
    int n,q;
    cin>>n>>q;
    Graph G(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        G.at(a).push_back(b);
        G.at(b).push_back(a);
    }
    vector<ll>ans(n,0);
    // cout<<"AAA"<<endl;

    for(int i=0;i<q;i++){
        int p,x;
        cin>>p>>x;
        ans.at(p-1)+=x;
        // ans.at(tree.root(p-1))+=x;
        // cout<<"AAA"<<endl;
        // cout<<"BBB"<<endl;
    }

    for(int i=0;i<n;i++){
        dfs(G,ans,i);
    }
    for(int i=0;i<n;i++){
        cout<<ans.at(i)<<endl;
    }





    return 0;
}


Measured memory_bytes: 15476
def main():
    a, b, k = map(int, input().split())
    for i in range(k):
        if i % 2 == 0:
            if a % 2 == 1:
                a -= 1
            a,b = a/2, b+a/2
        else:
            if b % 2 == 1:
                b -=1
            a,b = a+b/2, b/2
    print(int(a),int(b))
    pass

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

const MOD = 1000000007
const UBOUND = 400

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, c := nextInt(), nextInt()

	aArray := make([]int, n)
	for ni := range aArray {
		aArray[ni] = nextInt()
	}
	bArray := make([]int, n)
	for ni := range bArray {
		bArray[ni] = nextInt()
	}

	powMat := make([][]int, UBOUND+1)
	for r := range powMat {
		pow := make([]int, UBOUND+1)
		for i := range pow {
			if r == 0 {
				pow[i] = 1
				continue
			}
			pow[i] = (powMat[r-1][i] * i) % MOD
		}
		powMat[r] = pow
	}
	powCumSumMat := make([][]int, UBOUND+1)
	for r := range powCumSumMat {
		powCumSum := make([]int, UBOUND+1)
		for x := range powCumSum {
			if x == 0 {
				powCumSum[x] = powMat[r][x]
				continue
			}
			powCumSum[x] = (powCumSum[x-1] + powMat[r][x]) % MOD
		}
		powCumSumMat[r] = powCumSum
	}

	dp := make([][]int, c+1)
	for ci := range dp {
		dpLine := make([]int, n)
		dp[ci] = dpLine
	}

	for ci, dpLine := range dp {
		for ni := range dpLine {
			if ni == 0 {
				dp[ci][ni] = powCumSumMat[ci][bArray[ni]] - powCumSumMat[ci][aArray[ni]-1]
				switch {
				case dp[ci][ni] < 0:
					dp[ci][ni] += MOD
				default:
					dp[ci][ni] %= MOD
				}
				continue
			}
			for cj := 0; cj <= ci; cj++ {
				switch {
				case powCumSumMat[cj][bArray[ni]]-powCumSumMat[cj][aArray[ni]-1] < 0:
					dp[ci][ni] += dp[ci-cj][ni-1] * (powCumSumMat[cj][bArray[ni]] - powCumSumMat[cj][aArray[ni]-1] + MOD) % MOD
				default:
					dp[ci][ni] += dp[ci-cj][ni-1] * ((powCumSumMat[cj][bArray[ni]] - powCumSumMat[cj][aArray[ni]-1]) % MOD) % MOD
				}
				dp[ci][ni] %= MOD
			}
		}
	}
	fmt.Println(dp[c][n-1])
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vect vector<ll>
#define unmap unordered_map
#define pb push_back
#define pi 3.1415926536
#define mod int(1e9+7)
#define mp make_pair
#define testcases ll t; cin>>t; while(t--)

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

    int n;
    cin>>n;
    vector<vector<int>> v(n+1,vector<int>(3,0));

    for(int i=1;i<=n;i++)
    {
        cin>>v[i][0]>>v[i][1]>>v[i][2];
        v[i][0]+=max(v[i-1][1],v[i-1][2]);
        v[i][2]+=max(v[i-1][1],v[i-1][0]);
        v[i][1]+=max(v[i-1][0],v[i-1][2]);
    }
    cout<<max({v[n][1],v[n][0],v[n][2]});
    return 0;
}


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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int k, a, b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
}



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

vector<int> S(100000, -1);

int main(){
	long n, q;
	cin >> n >> q;
	for (long i = 0; i < n; i++){
		S[i] = i;
	}
	for (long i = 0; i < q; i++){
		long c, x, y;
		cin >> c >> x >> y;
		if (c == 0){
			long sx = S[x];
			long sy = S[y];
			for (long j = 0; j < n; j++){
				if (S[j] == sx){
					S[j] = sy;
				}
			}
		}
		else {
			if (S[x] == S[y]){
				cout << "1" << endl;
			}
			else {
				cout << "0" << endl;
			}
		}
		// for (long j = 0; j < n; j++){
		// 	if (j != 0) cout << " ";
		// 	cout << j;
		// }
		// cout << endl;
	}
	return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

int main(){
  string S;
  cin >> S;
  
  int dp[200010];
  int n = S.size();
  dp[n] = 0;
  int p = 2019;
  
  int n_10[200010];
  n_10[0] = 1;
  
  rep(i, 0, n){
    n_10[i+1] = n_10[i]*10%p;
  }
  
  int cnt[p];
  rep(i, 0, p)
    cnt[i] = 0;
  cnt[0]++;
  
  rep(i, 1, n+1){
    char c = S[n-i];
    int a = c - '0';
    
    dp[n-i] = dp[n-i+1] + (a * n_10[i-1] % p);
    dp[n-i] %= p;
    cnt[dp[n-i]]++;
  }
  
  ll ans = 0;
  
  rep(i, 0, p){
    int m = cnt[i];
    ans += m*(m-1)/2;
  }
  
  cout << ans << endl;
  
  return 0;
  
}

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

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

    vector<int> l(m);
    vector<int> r(m);

    REP(i, m) {
        cin >> l[i] >> r[i];
    }

    sort(l.rbegin(), l.rend());
    sort(r.begin(), r.end());

    cout << min(max(r[0]-l[0]+1, 0), n) << endl;

}


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

#define CARD_NUM 36

typedef struct {

  int value;
  char mark;

} card ;

void print_card(int N,card *card){

  int i;

  for(i = 0;i < N-1;i++){
    printf("%c",card[i].mark);
    printf("%d ",card[i].value);

  }
  printf("%c",card[N-1].mark);
  printf("%d\n",card[N-1].value);

}

void copy(int N,card _Source[],card *_Dest){

  int i;

  for(i = 0;i < N;i++){
    _Dest[i] = _Source[i];
  }
}

void isStable(int N,card *in,card *out){

  int i;
  int j;
  int a;
  int b;

  for(i = 0;i < N;i++){
    for(j = i+1;j < N;j++){
      for(a = 0;a < N;a++){
	for(b = a+1;b < N;b++){
	  if(in[i].value == in[j].value && 
	     in[i].value == out[b].value && 
	     in[i].mark == out[b].mark &&
	     in[j].value == out[a].value &&
	     in[j].mark == out[a].mark){
	    printf("Not stable\n");
	    return;
	  }
	}
      }
    }
  }
  printf("Stable\n");
}

void Bubble(int N,card C[]){

  int i;
  int j;
  int cnt = 0;
  card temp;
  card CC[N];

  copy(N,C,CC);

  for(i = 0;i < N;i++){
    for(j = N-1;j > i;j--){
      if(CC[j].value < CC[j-1].value){
	temp = CC[j];
	CC[j] = CC[j-1];
	CC[j-1] = temp;
      }
    }
  }

  print_card(N,CC);
  isStable(N,C,CC);
}

void Selection(int N,card *C){

  int i;
  int j;
  int min;
  int flag = 0;
  card temp;
  card CC[N];

  copy(N,C,CC);

  for(i = 0;i < N;i++){
    min = i;
    for(j = i;j < N;j++){
      if(CC[j].value < CC[min].value){
	min = j;
      }
    }
    temp = CC[i];
    CC[i] = CC[min];
    CC[min] = temp;
  }
  print_card(N,CC);
  isStable(N,C,CC);
}

int main(){

  int i;
  int num;
  char temp[4];
  card card1[CARD_NUM];

  scanf("%d",&num);

  for(i = 0;i < num;i++){
    scanf("%s",temp);
    card1[i].mark = *temp;
    card1[i].value = atoi(&temp[1]);
  }

  Bubble(num,card1);
  Selection(num,card1);

  return 0;
}

Measured memory_bytes: 612
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
p = [0] * 100005
for i in a:
    p[i] += 1

num = 0
for i in range(1, 100000):
    num = max(num, sum(p[i - 1: i + 2]))

print(num)

Measured memory_bytes: 14004
#include <algorithm>
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using ll = long long;
using namespace std;

vector<int> solve(int n, ll l, ll t, vector<int> const & x, vector<int> const & w) {
    ll cnt = 0;
    repeat (i, n) if (w[0] != w[i]) {
        int dx = x[i] - x[0];
        dx = (w[0] == 1 ? dx : l - dx);
        cnt += (2 * t - dx + l) / l;
    }
    cnt %= n;
    vector<int> y(n);
    int z = 0;
    repeat (i, n) {
        y[i] = ((x[i] + (w[i] == 1 ? +1ll : -1ll) * t) % l + l) % l;
        if (y[i] == y[0]) z = i;
    }
    int y_0 = y[0];
    sort(whole(y));
    int ofs = find(whole(y), y_0) - y.begin();
    if (z and w[0] < w[z]) ++ ofs;
    int shift = (w[0] == 1 ? - cnt + ofs + n : cnt + ofs) % n;
    rotate(y.begin(), y.begin() + shift, y.end());
    return y;
}

int main() {
    int n, l, t; scanf("%d%d%d", &n, &l, &t);
    vector<int> x(n), w(n); repeat (i, n) scanf("%d%d", &x[i], &w[i]);
    vector<int> y = solve(n, l, t, x, w);
    for (int y_i : y) {
        printf("%d\n", y_i);
    }
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000007
typedef long long int lint;

int main() {
  int N,now,ans = mod,av = 0;
  cin >> N;
  vector<int> a(N);
  rep(i,0,N){cin >> a[i]; av += a[i];}
  sort(a.begin(),a.end());
  av /= N;
  
  if(a[N/2] >= av){
    rep(i,av-1,a[N/2] + 2){
      now = 0;
      rep(j,0,N){
        now += (i - a[j])*(i - a[j]);
      }
      ans = min(ans,now);
    }
    co(ans);
  }
  else{
    rep(i,a[N/2]-1,av + 2){
      now = 0;
      rep(j,0,N){
        now += (i - a[j])*(i - a[j]);
      }
      ans = min(ans,now);
    }
    co(ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

bool isUnbalanced(std::string s) {
    if (s[0] == s[1]) return true;
    return (s.size() == 3 and (s[0] == s[2] or s[1] == s[2]));
}

int main() {
    std::string s;
    std::cin >> s;

    for (int i = 0; i < s.size() - 1; i++) {
        if (isUnbalanced(s.substr(i, 2))) {
            std::cout << i + 1 << " " << i + 2 << std::endl;
            return 0;
        }
        if (isUnbalanced(s.substr(i, 3))) {
            std::cout << i + 1 << " " << i + 3 << std::endl;
            return 0;
        }
    }

    std::cout << -1 << " " << -1 << std::endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-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;
}


void solve(long long N){
    double nuki=0, nuki_c=0, nuki_f=0;
    double komi=0, komi_c=0, komi_f=0;
    nuki=N/1.08;
    nuki_c=ceil(nuki);
    nuki_f=floor(nuki);
    // debg(nuki);
    // debg(nuki_c);
    // debg(nuki_f);
    komi=nuki*1.08;
    komi_c=floor(nuki_c*1.08);
    komi_f=floor(nuki_f*1.08);
    // debg(komi);
    // debg(komi_c);
    // debg(komi_f);
    ll val=0;
    if(komi_c==N){
        val=nuki_c;
    } else if (komi_f==N){
        val=nuki_f;
    } else {
        val=-1;
    }
    if(val!=-1){
        cout << val << "\n";
    }else{
        cout << ":(" << "\n";
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (long int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    string S;
    cin>>S;
    cout<<S[0]<<S[1]<<S[2]<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17

int main(){
    int n;string S;
    cin>>n>>S;
    VI a(n);
    int b=0,w=0;
    rep(i,n){
        if(S[i]=='.'){a[i]=0;w++;}
        else {a[i]=1;b++;}
    }
    VI sum(n+1);
    sum[0]=0;
    rep(i,n)sum[i+1]=sum[i]+a[i];
    int ans=n;
    rep(i,n+1){
        int res=0;
        res+=sum[i];
        res+=w-(i-sum[i]);
        chmin(ans,res);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6804
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x);
#define MAX (10000000)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int n,m,p;
  while(n=getInt(),m=getInt(),p=getInt(), n+m+p){
    int sum = 0;
    int hit;
    m--;
    REP(i,n){
      int t = getInt();
      sum += t * 100;
      if(m == i)
        hit = t;
    }

    if(hit == 0) puts("0");
    else print((int)((((double)(100-p)/100.0) * sum)/hit));
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int Y = 0;
  int64_t A = 2;
  int64_t B = 1;
  int64_t C = A + B;
  if (N == 1){
    cout << 1 << endl;
     Y = 1;
  }
  for (int i = 1; i < N; i++){
    int64_t A1 = A;
    int64_t B1 = B;
    int64_t C1 = A + B;
    A = B1;
    B = C1;
    C = A1 + B1;
  }
  if (Y == 0){
    cout << C <<endl;
  }
  
}

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

int main(){
  string S;
  cin>>S;
  int count=0;
  for(int i=0; i<S.size()/2; i++){
    if(S.at(i)!=S.at(S.size()-1-i)){
      S.at(i)=S.at(S.size()-1-i);
      count++;
    }
  }
  cout<<count<<endl;
}
  

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

int main() {
	int r, g, b, n;
	long long count = 0;

	cin >> r >> g >> b >> n;

	for (int i = 0; i <= n / r; i++) {
		for (int j = 0; j <= (n - r*i) / g; j++) {
			if ((n - r*i - g*j) % b == 0) {
				count++;
			}
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    vector<int> b(n-1);
    for(auto &x:b)cin >> x;

    vector<int> a(n,0);
    a[0]=b[0];
    a[1]=b[0];
    for(int i=0;i<n-1;i++){
        if(b[i]>=max(a[i],a[i+1])){
            a[i+1]=b[i];
        }else if(b[i]<max(a[i],a[i+1])){
            a[i]=b[i];
            a[i+1]=b[i];
        }
    }

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

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<int>graph[MAX];
int arr[MAX];
int vis[MAX];
vector<int>v;
map<int,int>mp;
void dfs(int src)
{
    vis[src]=1;
    mp[src]++;
    mp[arr[src]]++;
    v.push_back(src);
    for(int i=0; i<graph[src].size(); i++)
    {
        int child=graph[src][i];
        if(!vis[child])
            dfs(child);
    }
}
void fix()
{
    for(auto x:v)
    {
        if(mp[x]==2)
            arr[x]=x;

    }
    mp.clear();
    v.clear();
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        cin>>arr[i];
    while(m--)
    {
        int u,v;
        cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    for(int i=1; i<=n; i++)
    {
        if(graph[i].size() && !vis[i])
        {
            dfs(i);
            fix();
        }
    }
    int cnt=0;
    for(int i=1; i<=n; i++)
    {
        if(arr[i]==i)
            cnt++;
    }
    cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 41828
import java.util.Scanner;

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

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		System.out.println((g * 10 + b) % 4 == 0 ? "YES" : "NO");
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int h, w, field[55][55];

void dfs(int i, int j){
    field[i][j] = 0;

    for(int di=-1;di<=1;di++){
        for(int dj=-1;dj<=1;dj++){
            int ni = i + di, nj = j + dj;
            if(ni < 0 || ni >= h) continue;
            if(nj < 0 || nj >= w) continue;
            if(field[ni][nj] == 1){
                dfs(ni, nj);
            }
        }
    }
}

int main() {
    while(cin >> w >> h, w){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin >> field[i][j];
            }
        }
        int ans = 0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(field[i][j] == 1){
                    dfs(i,j);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}





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

const int MOD=1e9+7;
int a[10009];
int pt[1000010];

ll modpow(ll x,ll n){
    ll ans=1;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1; 
    }
    return ans;
}

int main(){
    int n;
    cin>>n;
    REP(i,n) {
        cin>>a[i];
        int tmp=a[i];
        for(int j=2;j*j<=tmp;j++){
            if(tmp%j!=0) continue;
            int cnt=1;
            while((tmp/=j)%j==0) ++cnt;
            pt[j]=max(pt[j],cnt);
        }
        if(tmp>1) pt[tmp]=max(pt[tmp],1);
    }
    
    ll s=1;
    ll ans=0;
    REP(i,1000000){
        while(pt[i]--) s=s*i%MOD;
    }  

    REP(i,n){
        ans=(ans+s*modpow(a[i],MOD-2))%MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;
typedef priority_queue<int, vector<int>, greater<int>> min_heap;

// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const double PI = 4*atan(1);
const ll INF = 1e18;
const int MX = 100001;


const int maxn = 2e3 + 5;
int n, x, y;

int d1[maxn], dn[maxn];
int visited[maxn];
vector<int> adj[maxn];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> x >> y;
    for (int i = 1; i < n; i++) {
        adj[i].pb(i + 1);
        adj[i + 1].pb(i);
    }
    adj[x].pb(y);
    adj[y].pb(x);
    queue<pi> q;
    q.push({0, x});
    visited[x] = 1;
    while(!q.empty()) {
        pi p = q.front();
        q.pop();
        int d = p.f;
        int u = p.s;
        d1[u] = d;
        for (int v: adj[u]) {
            if (!visited[v]) {
                q.push(mp(d + 1, v));
                visited[v] = 1;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        visited[i] = 0;
    }
    q.push({0, y});
    visited[y] = 1;
    while(!q.empty()) {
        pi p = q.front();
        q.pop();
        int d = p.f;
        int u = p.s;
        dn[u] = d;
        for (int v: adj[u]) {
            if (!visited[v]) {
                q.push(mp(d + 1, v));
                visited[v] = 1;
            }
        }
    }
    vector<int> ans(n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int d_1 = j - i;
            int d_2 = d1[i] + 1 +  dn[j];
            int k = min(d_1, d_2);
            ans[k]++;;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

const int Maxn = 10000;
int n;

int main ()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if (b <= c || a >= d) printf("0");
	else {
		int s = max(a,c);
		int t = min(b,d);
		printf("%d",t-s);
		}
	return 0;
	}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>

int main(){
    char str[1001];
    
    while(1){
        scanf("%s",str);
        if(str[0]=='0')break;
        int sum=0;
        for(int i=0;i<strlen(str);i++){
            sum += (str[i]-'0');
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 2592
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def myAnswer(N:int,X:int,x:list) -> int:
   ans = []
   for a in x:
      ans.append(abs(a-X))
   return gcd_list(ans)

def modelAnswer():
   return
def main():
   N,X = map(int,input().split())
   x = list(map(int,input().split()))
   print(myAnswer(N,X,x[:]))
if __name__ == '__main__':
   main()




Measured memory_bytes: 16268
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int t=1;
	//cin>>t;
	while(t--){
		int a,b,c;
		int k;
		cin>>a>>b>>c>>k;
		int ct=0;
		while(a>=b){
			b*=2;
			ct++;
		}
		while(c<=b){
			c*=2;
			ct++;
		}
		if(ct<=k)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) ( ((a) + ((b) - 1) ) / b)

typedef long long int lli;

using namespace std;

int main(void) {
	int H, W;
	int X[90001];
	int Y[90001];
	int D;
	int Q;
	int d[90001];
	scanf("%d %d %d", &H, &W, &D);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int x;
			scanf("%d", &x);
			X[x] = j;
			Y[x] = i;
		}
	}
	scanf("%d", &Q);

	memset(d, 0, sizeof(int) * 90001);
	for (int i = D + 1; i <= H * W; i++) {
		d[i] = d[i-D] + abs(X[i] - X[i-D]) + abs(Y[i] - Y[i-D]);
	}

	while (Q--) {
		int L, R;
		scanf("%d%d", &L, &R);
		printf("%d\n", d[R] - d[L]);
	}
	return 0;
}


Measured memory_bytes: 2176
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {_a:usize, _b:usize, _c:usize, _x:usize}
    let mut ans: usize = 0;
    for i in 0..(_a + 1) {
        for j in 0..(_b + 1) {
            for k in 0..(_c + 1) {
                if i * 500 + j * 100 + k * 50 == _x {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#define P(x) cout << #x " = " << x << endl
#define PP(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define PPP(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl

#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<string>

using namespace std;
int h, w, n;
int si, sj;
string s1, s2;
bool f(int mx, int start, char fwd, char rev){
    int low = -1;
    int high = mx;
    for (int i = n - 1; i >= 0; --i) {
        if (s2[i] == fwd && low > -1) low--;
        if (s2[i] == rev && high < mx) high++;
        if (s1[i] == fwd) high--;
        if (s1[i] == rev) low++;
        if (low + 1 >= high) return false;
    }
    return (low < start && start < high);
}
int main()
{
    cin >> h >> w >> n >> si >> sj;
    si--;
    sj--;
    cin >> s1 >> s2;
    cout << (f(h, si, 'D', 'U') && f(w, sj, 'R', 'L') ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1020
H, A = map(int, input().split())


if H % A == 0:
    count_e = H//A 
    print(count_e)

elif H < A:
    count_u =  1
    print(count_u)
    
elif  H % A != 0:
    count_o = H // A + 1
    print(count_o)
    


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define All(a) (a).begin(),(a).end()

void solve(){
  ll n,m,x,y,cnt=0;
  cin >> n;

  for(int i=0; i < n; i++){
    cin >> x >>y;
    if(x==y)cnt++;
    else cnt=0;
    if(cnt==3){
      cout<<"Yes"<<endl;
      return;
    }
  }
  cout<<"No"<<endl;

}
int main(){
  /*
  int q;
  scanf("%d",&q);
  while(--q)solve();
  */
  solve();

  return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=998244353
    N=I()
    A=LI()
    MA=max(A)
    x=[0]*(MA+1)
    
    #数列x[i]はi*(iの個数)
    for i in range(N):
        x[A[i]]+=A[i]
        
    #print(x)
    
    #上位集合のゼータ変換
    for k in range(1,MA+1):
        for s in range(k*2,MA+1,k):#sが2kからkずつ増える=>sはkの倍数(自分自身を数えないため，2kから)
            x[k]=(x[k]+x[s])%mod
    
    #print(x)
    #この段階でx[i]はiを約数に持つやつの和(個数も加味している)
    
    #積演算
    for i in range(MA+1):
        x[i]=(x[i]*x[i])%mod
        
    #print(x)
    
    
    #メビウス変換で戻す
    for k in range(MA,0,-1):
        for s in range(k*2,MA+1,k):
            x[k]=(x[k]-x[s])%mod
            
    #この段階でx[i]はiをgcdに持つもの同士をかけたものの和
    #print(x)
    
    #gcdでわる
    ans=0
    for i in range(1,MA+1):
        if x[i]!=0:
            x[i]=(x[i]*pow(i,mod-2,mod))%mod
            ans=(ans+x[i])%mod
        
    #この段階でx[i]はiをgcdに持つもの同士のlcaの和
    #print(x)
        
    ans=(ans-sum(A))%mod
    #A[i],A[i]の組を除去する．A[i]動詞のくみはlcaがA[i]になる
       
    """ 
    ans=(ans*pow(2,mod-2,mod))%mod#A[i]*A[j] と　A[j]*A[i]の被り除去
    print(pow(2,mod-2,mod))=499122177
    """
    ans=(ans*499122177)%mod
    
    print(ans)
        
    
    

main()


Measured memory_bytes: 116172
A, B, K = input().split()
A = int(A)
B = int(B)
K = int(K)

min = A if A <= B else B

list = []
for i in range(1, min+1):
    if A % i == 0 and B % i == 0:
        list.append(i)

print(list[len(list)-K])

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

using namespace std;

typedef long long ll;

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

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

	ll n;
	cin >> n;

	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	bool up = false;
	ll stk = 0;
	ll mon = 1000;
	rep(i, n - 1){
		if(up && a[i+1] < a[i]){
			up = false;
			mon += stk * a[i];
			stk = 0;
		}

		if(!up && a[i+1] > a[i]){
			up = true;
			stk += mon / a[i];
			mon -= mon / a[i] * a[i];
		}
	}

	mon += stk * a[n-1];

	cout << mon << endl;
}


Measured memory_bytes: 3648