akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n;
    cin>>n;

    ll ans=0;
    rep(i,n+1){
       if(i%3==0 || i%5==0)continue;
       ans+=i;
    }

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 3672
import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

n = int(rl())
li = [list(map(int, rl().split())) for _ in range(n)]
dp = [[0]*3 for _ in range(n)]
dp[0] = li[0]

for i in range(1, n):
    a = dp[i-1][1] + li[i][0]
    b = dp[i-1][2] + li[i][0]
    dp[i][0] = max(a, b)
    a = dp[i-1][0] + li[i][1]
    b = dp[i-1][2] + li[i][1]
    dp[i][1] = max(a, b)
    a = dp[i-1][0] + li[i][2]
    b = dp[i-1][1] + li[i][2]
    dp[i][2] = max(a, b)
print(max(dp[-1]))

    



Measured memory_bytes: 56520
#include<stdio.h>
#include<stdlib.h>
int mycomp(const void* pt, const void* pt1);
int main()
{
	long int ar[200001] = { 0 };
	long int n;
	scanf("%ld", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%ld", &ar[i]);
	}
	qsort(ar + 1, n, sizeof(long int), mycomp);
	for (int i = 1; i < n; i++) {
		if (ar[i] == ar[i + 1]) {
			printf("NO"); return 0;
		}
	}
	printf("YES");
	return 0;
}
int mycomp(const void* pt, const void* pt1)
{
	const long int* st = (const long int*)pt;
	const long int* st1 = (const long int*)pt1;
	return *st - *st1;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    if(n%2==1){
        cout << "0" << "\n";
        return 0;
    }

    ll cnt=0;
    ll div=10;
    while(div<=n) {
        ll tmp=n/div;
        cnt+=tmp;
        div*=5;
    }
    cout << cnt << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vc vector<char> 
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
int n,a,b,c;vc ans;bool AB,BC,AC;
void solve(int &x,int &y,char X,char Y)
{
	if(x==y&&!x)
	{
		cout<<"No\n";
		exit(0);
	}
	if(x>y)x--,y++,ans.pb(Y);
	else x++,y--,ans.pb(X);
}
string dp[4][4][4][N];
void print(int A,int B,int C,int now)
{
	if(now==0)return;
	string c=dp[A][B][C][now];
	if(c=="AB")print(A-1,B+1,C,now-1),cout<<"A\n";
	if(c=="AC")print(A-1,B,C+1,now-1),cout<<"A\n";
	if(c=="BA")print(A+1,B-1,C,now-1),cout<<"B\n";
	if(c=="BC")print(A,B-1,C+1,now-1),cout<<"B\n";
	if(c=="CA")print(A+1,B,C-1,now-1),cout<<"C\n";
	if(c=="CB")print(A,B+1,C-1,now-1),cout<<"C\n";
}
void solution2()
{
	dp[a][b][c][0]=" ";
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		for(int A=0;A<=3;A++)
		{
			for(int B=0;B<=3;B++)
			{
				for(int C=0;C<=3;C++)
				{
					if(dp[A][B][C][i]=="")continue;
					if(s=="AB"){
						if(A!=0)dp[A-1][B+1][C][i+1]="BA";
						if(B!=0)dp[A+1][B-1][C][i+1]="AB";
					}else if(s=="AC"){
						if(A!=0)dp[A-1][B][C+1][i+1]="CA";
						if(C!=0)dp[A+1][B][C-1][i+1]="AC";
					}else{
						if(B!=0)dp[A][B-1][C+1][i+1]="CB";
						if(C!=0)dp[A][B+1][C-1][i+1]="BC";
					}
				}
			}
		}
	}
	for(int A=0;A<=3;A++)
		for(int B=0;B<=3;B++)
			for(int C=0;C<=3;C++)
				if(dp[A][B][C][n]!="")
				{
					cout<<"Yes\n";
					print(A,B,C,n);
					return;
				}
	cout<<"No\n";
	return;
}
int main()
{
	cin>>n>>a>>b>>c;
	if(a+b+c<=3)
	{
		solution2();
		return 0;
	}
	while(n--)
	{
		string s;
		cin>>s;
		if(s=="AB")solve(a,b,'A','B');
		else if(s=="BC")solve(b,c,'B','C');
		else solve(a,c,'A','C');
	}
	cout<<"Yes\n";
	rep(i,ans.size())cout<<ans[i]<<"\n";
	return 0;
}

Measured memory_bytes: 217612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> h(n);
	rep(i,n) cin >> h.at(i);
	int ans = 0, sum = 0;
	for(int i = n - 2; i >= 0; i--){
		if(h.at(i) >= h.at(i + 1)) sum++;
		else{
			ans = max(ans,sum);
			sum = 0;
		}
	}
	ans = max(ans,sum);
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int table[100+1][100+1]={};
	int r, c;
	int i, j;


	scanf("%d %d", &r, &c);

	for(i=0; i<r; i++) {
		for(j=0; j<c; j++) {
			scanf("%d", &table[i][j]);
			table[i][c] += table[i][j];
		}
	}

	for(j=0; j<=c; j++) {
		for(i = 0; i<r; i++) {
			table[r][j] += table[i][j];
		}
	}



	for(i=0; i<=r; i++) {
		for(j=0; j<c; j++) {
			printf("%d ", table[i][j]);
		}
		printf("%d\n", table[i][c]);
	}

	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 h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(is,1<<h)rep(js,1<<w) {
    int cnt = 0;
    rep(i,h)rep(j,w) {
      if (is>>i&1) continue;
      if (js>>j&1) continue;
      if (s[i][j] == '#') cnt++;
    }
    if (cnt == k) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3584
def main():
  n=int(input())
  dp=[[0,0,0]]
  for i in range(1,n+1):
    a,b,c=map(int,input().split())
    dp.append([max(dp[i-1][1],dp[i-1][2])+a,max(dp[i-1][0],dp[i-1][2])+b,max(dp[i-1][0],dp[i-1][1])+c])
    #print(dp)
  print(max(dp[n]))
if __name__=='__main__':
  main()

Measured memory_bytes: 28632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double num1 = 0.5*m + 30*h;
		double num2 = 6*m;
		double num3 = 0;
		
		if(num1 > num2) {
			num3 = num1 - num2;
		} else if (num2 > num1){
			num3 = num2 - num1;
		}
		
		if(num3 > 180) {
			num3 = 360- num3;
		}
		


		double cos =  Math.cos(Math.toRadians(num3));
		double c = (a*a+b*b)-(2*a*b*cos);
		double ans = Math.sqrt(c);
		System.out.println(ans);
	}
}


Measured memory_bytes: 37360
N=int(input())
A=[int(x)for x in input().split()]
array=[0]*9
def wake(x):
    if x<3200:
        array[x//400]+=1
    else:
        array[8]+=1
    return
for i in A:
    wake(i)
ans1=sum(1 for x in array[:-1]if x>0)
ans=8-array.count(0)
if array[8]==0:
    ans+=1
else:
    ans+=array[8]

if ans1==0:
    ans1+=1

print(ans1,ans)

    
    
        

Measured memory_bytes: 3064
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = N/500;
    int B = N%500;
    int C = B/5;

    System.out.println(A*1000 + C*5);
}
}

Measured memory_bytes: 21844
def c_synthetic_kadomatsu(N, A, B, C, L):
    from itertools import permutations
    # for j in range(1, N):
    #     for k in range(1, N - j):
    #         for l in range(1, N - j - k + 1):
    #             print(j, k, l, L[:j], L[j:j + k], L[j + k:j + k + l])
    ans = float('inf')
    for perm in permutations(range(N)):
        for j in range(1, N):
            for k in range(1, N - j):
                for l in range(1, N - j - k + 1):
                    cost = 0
                    s, t, u = perm[:j], perm[j:j + k], perm[j + k:j + k + l]
                    a, b, c = [], [], []
                    for _s in s:
                        a.append(L[_s])
                    for _t in t:
                        b.append(L[_t])
                    for _u in u:
                        c.append(L[_u])
                    cost += (len(a) + len(b) + len(c) - 3) * 10
                    cost += abs(sum(a) - A) + abs(sum(b) - B) + abs(sum(c) - C)
                    ans = min(ans, cost)
    return ans

N, A, B, C = [int(i) for i in input().split()]
L = [int(input()) for _ in range(N)]
print(c_synthetic_kadomatsu(N, A, B, C, L))

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

using namespace std;

int main(){
  int N; cin >> N; int sum = 0; vector<int>vec(N);
  int maxp = 0;
  for(int i = 0; i < N; i++){
    int a; cin >> a; vec[i] = a; maxp = max(maxp,a);  sum += a; }
  
  cout << sum - (maxp / 2) << endl;
  
  return 0;}
  


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    int result = A - 2 * B;
    if (result > 0) {
        cout << result;
    } else {
        cout << 0;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = nm[0];
            var m = nm[1];
            if(m == 0)
            {
                Console.WriteLine(1);
                return;
            }

            var G = new List<List<int>>(); 
            for(int i = 0; i < n; i++)
            {
                G.Add(new List<int>());
            }

            for (int i = 0; i < m; i++)
            {
                var ab = Console.ReadLine().Split();
                var a = int.Parse(ab[0]) - 1;
                var b = int.Parse(ab[1]) - 1;

                G[a].Add(b);
                G[b].Add(a);
            }

            var ans = 0;
            var visited = new bool[n];
            var que = new Queue<int>();

            for(int i = 0; i < n; i++)
            {
                if (visited[i])
                {
                    continue;
                }

                var count = 0;

                que.Enqueue(i);
                while (que.Any())
                {
                    var x = que.Dequeue();

                    foreach(var nx in G[x])
                    {
                        if (visited[nx])
                        {
                            continue;
                        }

                        visited[nx] = true;
                        que.Enqueue(nx);
                        count++;
                    }
                }
                if(count > ans)
                {
                    ans = count;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 63028
#include<stdio.h>

int mat[8][8];

int pos(int i, int j){
  if(i<8&&j<8&&mat[i][j])
    return 1;
  else
    return 0;
}

int main(){
  int i,j,c;

  for(;;){
    for(i=0;i<8;i++){
      for(j=0;j<8;j++){
	for(;;){
	  c=getchar();
	  if(c>='0'&&c<='9'){
	    mat[i][j]=c-'0';
	    break;
	  }
	  else if(c==EOF)
	    return 0;
	}
      }
    }
    
    for(i=0;i<8;i++){
      for(j=0;j<8;j++){
	if(pos(i,j)){
	  if(      pos(i,j+1) && pos(i+1,j)   && pos(i+1,j+1) )
	    puts("A");
	  else if( pos(i+1,j) && pos(i+2,j)   && pos(i+3,j)   )
	    puts("B");
	  else if( pos(i,j+1) && pos(i,j+2)   && pos(i,j+3)   )
	    puts("C");
	  else if( pos(i+1,j) && pos(i+1,j-1) && pos(i+2,j-1) )
	    puts("D");
	  else if( pos(i,j+1) && pos(i+1,j+1) && pos(i+1,j+2) )
	    puts("E");
	  else if( pos(i+1,j) && pos(i+1,j+1) && pos(i+2,j+1) )
	    puts("F");
	  else if( pos(i,j+1) && pos(i+1,j)   && pos(i+1,j-1) )
	    puts("G");
	}
      }
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<char,char> p2;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,q,res=0;
    string s;
    cin>>n>>q>>s;
    vector<p2> v(q);
    for(ll i=0;i<q;i++)
    cin>>v[i].first>>v[i].second;
    ll l=0,r=n-1;
    while(l<=r){
        ll m=(l+r)/2;
        ll pos=m;
        for(ll i=0;i<q;i++)
        if(pos>=0&&pos<n&&s[pos]==v[i].first)
        pos+=(v[i].second=='R'?1:-1);
        if(pos==(-1))
        l=m+1;
        else
        r=m-1;
    }
    res-=r+1;
    l=0;
    r=n-1;
    while(l<=r){
        ll m=(l+r)/2;
        ll pos=m;
        for(ll i=0;i<q;i++)
        if(pos>=0&&pos<n&&s[pos]==v[i].first)
        pos+=(v[i].second=='R'?1:-1);
        if(pos==n)
        r=m-1;
        else
        l=m+1;
    }
    res+=l;
    cout<<res;
}


Measured memory_bytes: 976
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                {
                    let mut out = Vec::<u8>::new();
                    solve($input,&mut out);
                    let out_str =str::from_utf8(&out).unwrap();
                    assert_eq!(&out_str, &$output);
                }
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
#[allow(unused_mut)]
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr,str) => {
        $iter.next().unwrap()
    };

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

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    let mut out = std::io::stdout();

    solve(&stdin!(), &mut out);
}

#[allow(unused_mut)]
fn solve<W: std::io::Write>(src: &str, out: &mut W) {
    #[allow(unused_macros)]
    macro_rules! out {
        ($fmt:expr) => {{
            let _ = out.write_fmt(format_args!($fmt));
        }};
        ($fmt:expr, $($args:tt)*) => {{
            let _ = out.write_fmt(format_args!($fmt, $($args)*));
        }};
    }
    #[allow(unused_macros)]
    macro_rules! outln {
        ($fmt:expr) => {{
            out!(concat!($fmt,"
"));
        }};
        ($fmt:expr, $($args:tt)*) => {{
            out!(concat!($fmt, "
"), $($args)*);
        }};
    }

    input! {
        source = src,
        s:chars,
    }

    let mut c = 0;
    let mut m = 0;

    for &si in s.iter() {
        if si == 'S' {
            c = 0;
        } else {
            c += 1;
            m = max(m, c);
        }
    }
    out!("{}", m);
}
test! {}


Measured memory_bytes: 2068
/*
 * ARC095_D.cpp
 *
 *  Created on: May 18, 2018
 *      Author: 13743
 */
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

int a[100000];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	REP(i, N) {
		cin >> a[i];
	}
	sort(a, a+N);

	int n = a[N-1];
	int r = min(a[0], n - a[0]);
	int solR = a[0];
	FOR(i, 1, N-2) {
		int x = min(a[i], n - a[i]);
		if(x > r) {
			r = x;
			solR = a[i];
		}
	}
	cout << n << " " << solR << endl;
}






Measured memory_bytes: 640
n = int(input())
if n < 105:
    print(0)
elif n in range(105, 135):
    print(1)
elif n in range(135, 165):
    print(2)
elif n in range(165, 189):
    print(3)
elif n in range(189, 195):
    print(4)
else:
    print(5)




Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

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

	int t = x / 500;
	x %= 500;
	int f = x / 5;
	cout << t*1000 + f*5 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while(cin>>n,n) 
	{
		int in[n];
		for(int i = 0; i < n; ++i)
		{
			cin>>in[i];
		}
		sort(in,in+n);
		int ans=0;
		for(int i = 1; i < n-1; ++i)
		{
			ans+=in[i];
		}
		cout<<ans/(n-2)<<endl;
	}
  return 0;
}

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

int main(void){
  int n,x,y; cin >> n >> x >> y;
  x--;y--;
  //vector<int> dist(n,-1);
  //queue<int> q;

  queue<int> q;
    
  vector<int> ans(n,0);  
  rep(sv,n){
    vector<int> dist(n,-1);
    auto push = [&](int v,int d){
      //if(d != -1) return;
      if(dist[v] != -1) return;
      dist[v]=d;
      q.push(v);
    };
    push(sv,0);
    
    while(!q.empty()){ //BFS
      int v = q.front(); q.pop();      
      int d = dist[v];
      //if(d != -1) continue;
      
      if(v-1>=0) push(v-1,d+1);
      if(v+1<n) push(v+1,d+1);
      if(v == x) push(y,d+1);
      if(v == y) push(x,d+1);
    }
    rep(i,n) ans[dist[i]]++;
  }

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


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

int main(){
    int n;cin >> n;
    int sum=0;
    int a = n;

    do {
        if (a == 0){
            break;
        }
        int b = a % 10;
        a /= 10;

        sum += b;
    } while(1);
    

    if (n % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define scan(a) scanf("%d",&a)
#define scan2(a,b) scanf("%d %d",&a,&b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define print(x) printf("%d\n",x)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
static const int INF = 0x3f3f3f3f;
static const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD = 1e9+7;
const ll mod = 998244353;


int main()
{
    int a,b;
    cin>>a>>b;
    cout<<(a+b/2)<<endl;
    
    return 0;
}


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

using namespace std;

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

  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for (int i = 0; i <= a; ++i) {
    for (int j = 0; j <= b; ++j) {
      for (int k = 0; k <= c; ++k) {
        if (i * 500 + j * 100 + k * 50 == x) {
          ++ans;
        }
      }
    }
  }
  cout << ans << "\n";
}


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

int a[20];
int x[20][20];
int y[20][20];

void solve () {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    for (int j = 1; j <= a[i]; ++j) {
      cin >> x[i][j] >> y[i][j];
    }
  }
  int ans = 0;
  for (int bit = 1; bit < (1<<n); ++bit) {
    bitset<20> b(bit);
    bool ok = true;
    for (int p = 1; p <= n && ok; ++p) {
      if (b.test(p-1)) {
        for (int j = 1; j <= a[p]; ++j) {
          if (b.test(x[p][j]-1) != y[p][j]) ok = false;
        }
      }
    }
    if (ok) ans = max(ans, (int)b.count());
  }
  cout << ans << endl;
}
int main () {
  cin.tie(0), ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include<string.h>
#include <math.h>
#include <stack>
#define ll long long
using namespace std;

typedef struct A {
	int n;
	bool operator < (const A &o)const {
		return n > o.n;
	}
};
priority_queue<int> max_heap;
priority_queue<A> min_heap;
int main() {
	int n, a, b, c;
	scanf("%d", &n);
	int cnt = 0;
	ll t = 0;
	ll res = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		if (a == 1) {
			scanf("%d %d", &b, &c);
			t += c;
			cnt++;
			if (max_heap.size() == min_heap.size()) {
				if (min_heap.empty()) {
					max_heap.push({ b });
					res = 0;
				}
				else {
					if (min_heap.top().n > b) {
						max_heap.push({ b });
						res += max_heap.top() - b;
					}
					else {
						int tmp = min_heap.top().n;
						min_heap.pop();
						max_heap.push(tmp);
						min_heap.push({ b });
						res += b - max_heap.top();
					}
				}
			}
			else {
				if (max_heap.top() < b) {
					min_heap.push({ b });
					res += b - max_heap.top();
				}
				else {
					int tmp = max_heap.top();
					max_heap.pop();
					min_heap.push({ tmp });
					max_heap.push(b);
					res += min_heap.top().n - b;
				}
			}
		}
		else {
			int tmp = max_heap.top();
			printf("%d %lld\n", tmp, res + t);
		}
	}
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
#define ll unsigned long long
#define vi vector<int>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
using namespace std;
int main()
{
int n;
cin>>n;
if(n==1)
{cout<<"Hello World";return 0;}
int a,b;
cin>>a>>b;
cout<<(a+b);

}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int s = sc.nextInt();
        int ms = (n-1) * 50;
        s = Math.min(s, ms);
        int[] a = new int[m];
        int[] u = new int[m];
        int[] v = new int[m];
        int[] b = new int[m];
        int[] c = new int[n];
        int[] d = new int[n];
        ArrayList<Integer>[] nexts = new ArrayList[n];
        for(int i=0; i<n; i++) {
            nexts[i] = new ArrayList<Integer>();
        }
        for(int i=0; i<m; i++) {
            u[i] = sc.nextInt()-1;
            v[i] = sc.nextInt()-1;
            nexts[u[i]].add(i);
            nexts[v[i]].add(i);
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        for(int i=0; i<n; i++) {
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }
        Set<Long> visited = new HashSet<Long>();
        State init = new State(0, s, 0);
        PriorityQueue<State> q = new PriorityQueue<>();
        long[] res = new long[n];
        int rem = n-1;
        q.add(init);
        while(!q.isEmpty()) {
            State st = q.poll();
            if(visited.contains(st.ps())) continue;
            if(st.p != 0 && res[st.p] == 0) {
                res[st.p] = st.d;
                rem--;
                if(rem == 0) break;
            }
            visited.add(st.ps());
            int ns = st.s + c[st.p];
            ns = Math.min(ns, ms);
            long nd = st.d + d[st.p];
            State nextState = new State(st.p, ns, nd);
            if(!visited.contains(nextState.ps())) {
                q.add(nextState);
            }
            for(int i=0; i<nexts[st.p].size(); i++) {
                int j = nexts[st.p].get(i);
                int np = u[j];
                if(u[j] == st.p) np = v[j];
                if(st.s < a[j]) continue;
                nextState = new State(np, st.s-a[j], st.d+b[j]);
                if(!visited.contains(nextState.ps())) {
                    q.add(nextState);
                }
            }
        }

        for(int i=1; i<n; i++) {
            System.out.println(res[i]);
        }



    }

    static class State implements Comparable<State>{
        int p;
        int s;
        long d;
        public State(int p, int s, long d) {
            this.p = p;
            this.s = s;
            this.d = d;
        }
        public int compareTo(State st) {
            return Long.compare(d, st.d);
        }
        long ps() {
            return ((long)p << 32) + s;
        }
    }

}

Measured memory_bytes: 87384
import java.util.Scanner;

public class Main {
    private static int mod = 2019;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String[] s = scan.next().split("");
        scan.close();

        int[] amari = new int[2019];
        amari[0] = 1;
        int tenMod = 1;
        int nowMod = 0;
        for (int i = s.length - 1; i >= 0; i--) {
            nowMod += tenMod * Integer.parseInt(s[i]);
            nowMod %= mod;
            amari[nowMod]++;

            tenMod *= 10;
            tenMod %= mod;
        }

        long ans = 0;
        for (int i = 0; i < amari.length; i++) {
            ans += amari[i] * (amari[i] - 1) / 2;
        }
        System.out.println(ans);
    }
}


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

int main() {

	int N, K; cin >> N >> K;

	vector<int> h(N);

	for (int i = 0;i < N;i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end());

	int ans = h[N-1];
	for (int i = 0; i < N - (K-1); i++) {
		ans = min(ans, h[i + (K-1)] - h[i]);

	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

const double pi = 3.14159265358979;

int main() {
  int a, b, C;
  cin >> a >> b >> C;
  double r = C * pi / 180.0;
  double h = b * sin(r);
  double S = 0.5 * a * h;
  double l = a - b * cos(r);
  double L = a + b + sqrt(h * h + l * l);
  printf("%.8f %.8f %.8f\n", S, L, h);
  fflush(stdout);
  return 0;
}



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

int main(){
    string S;
    cin >> S;
    string ans = "None";
    for(int i = 'a'; i <= 'z'; i++){
        bool aru = false;
        for(char ch: S){
            if(ch == (char)i){
                aru = true;
            }
        }
        if(aru == false){
            ans = (char)i;
            break;
        }
    }
    cout << ans << endl;
}   

Measured memory_bytes: 512
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I:=h*w]*I
m+=d,
q=[a:=~w+a*w+b]
d[a]=1
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   if'.'!=m[(i:=s//w+y*~z)][(j:=s%w+x*~z)]or d[s]>=d[(t:=i*w+j)]:break
   if-~d[s]<d[t]:q+=t,;d[t]=d[s]+1
print(d[~w+f*w+g]%I-1)

Measured memory_bytes: 66284
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long ans = 0;
		HashMap<String,Long> sk = new HashMap<String,Long>();
		for(int i=0;i<n;i++) {
			String s = sc.next();
			String[] po = s.split(""); 
			Arrays.sort(po);
			s =String.join("",po);
			if(sk.containsKey(s)) {
				sk.put(s, sk.get(s)+1);
			}else {
				sk.put(s, 1l);
			}
		}
		for(long i:sk.values()) {
			ans+= (i-1)*(i)/2;
		}
		System.out.println(ans);
	}
}

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


struct P{
  double s,t;
};

void kc(int n,struct P a,struct P b){
  if(n == 0)return;
  struct P x,y,z;
  double th = M_PI *60.0/180.0;

  x.s = (2.0*a.s+1.0*b.s) / 3.0;
  x.t = (2.0*a.t+1.0*b.t) / 3.0;
  y.s = (1.0*a.s+2.0*b.s) / 3.0;
  y.t = (1.0*a.t+2.0*b.t) / 3.0;
  z.s = (y.s -x.s) * cos(th) - (y.t -x.t) * sin(th) + x.s;
  z.t = (y.s -x.s) * sin(th) + (y.t -x.t) * cos(th) + x.t;

  kc(n-1,a,x);
  printf("%.8f %.8f\n",x.s,x.t);
  kc(n-1,x,z);
  printf("%.8f %.8f\n",z.s,z.t);
  kc(n-1,z,y);
  printf("%.8f %.8f\n",y.s,y.t);
  kc(n-1,y,b);
}

int main(){
  struct P a,b;
  int l;
  scanf("%d",&l);

  a.s = 0;
  a.t = 0;
  b.s = 100;
  b.t = 0;

  printf("%.8f %.8f\n",a.s,a.t);
  kc(l,a,b);
  printf("%.8f %.8f\n",b.s,b.t);

  return 0;
}


Measured memory_bytes: 2000
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let c1:Vec<char> = read::<String>().chars().collect();
    let c2:Vec<char> = read::<String>().chars().collect();
    let c3:Vec<char> = read::<String>().chars().collect();
    let ans = format!("{}{}{}",c1[0],c2[1],c3[2]);
    println!("{}",ans);
}

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

int main() {
  
  while (true) {
    
    int n; cin >> n; if (n == 0) return 0;
    
    double result[n];
    
    double sum = 0; double tmp = 0;
    
    for (int i = 0; i < n; i++) {
      int s; cin >> s;
      result[i] = s; sum += s;
    }
    
    double m = (double)sum / (double)n;
    
    for (int i = 0; i < n; i++) {
      tmp += pow((double)result[i] - m, 2);
    }
    
    cout << fixed << setprecision(10);
    
    cout << sqrt(tmp / (double)n) << endl;
    
  }
  
}


Measured memory_bytes: 3300
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
 
signed main(){
 
	string s;
	cin>>s;
 
 
	lli ans=0;
	lli start=0;
	lli size = s.size();
	for(lli i=0;i<(lli)size-2;i++){
		if(s[i]!='A')start=i+1;
 
		if(s[i]=='A' && s[i+1]=='B'&&s[i+2]=='C'){
			ans+=i-start+1;
			s[start]='B';
			s[start+1]='C';
			lli cnt=0;
			for(lli j=i+2;j>=start+2;j--){
			//for(lli j=start+2;j<=i+2;j++) {
				s[j]='A';
				cnt++;
				if(cnt>=3)break;
			}
			start=start+2;
		}
	}
	
	cout<<ans<<endl;
 
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int n,m;

	scanf("%d %d", &n, &m);
	int A[n][m];
	int B[m];
	int C[n];
	int i,j;

	for(i=0; i<n; i++)
		C[i] = 0;

	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			scanf("%d",&A[i][j]);
		}
	}
	for(i=0; i<m; i++)
		scanf("%d", &B[i]);

	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			C[i] += A[i][j]*B[j];
		}
	}
	for(i=0; i<n; i++)
		printf("%d\n",C[i]);

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const 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 ALL(v) (v).begin(), (v).end()

map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}


int main() {
    ll n, p, ans=1;
    map<ll,ll> fact;
    cin >> n >> p;
    fact = prime_factor(p);
    for(auto f : fact){
        if(f.second>=n) ans *= ll(pow(f.first,ll(f.second/n)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int id=0;
	int num=0;
	for(int i=a.length()-1;i>=0;--i){
		if(a[i]!=b[id++]){
			cout<<"NO";
			num=1;
			break;
		}
	}
	if(num==0) cout<<"YES";
}

Measured memory_bytes: 256
import itertools 
import math
N = int(input())
d = [list(map(int,input().split())) for i in range(N)]
ans = 0
cnt = 0
for i in itertools.permutations(d, N):
  cnt += 1
  for j in range(len(i)-1):
    ans += math.sqrt((i[j][0]-i[j+1][0])**2+(i[j][1]-i[j+1][1])**2) 
print(ans/cnt)

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

using namespace std;

int main(void){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int ans = 0;
  for(int a = 0; a <= A; a++){
    for(int b = 0; b <= B; b++){
      for(int c = 0; c <= C; c++){
        if(X == 500 * a + 100 * b + 50 * c) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    long long int n,i;
    string ans = "";
    cin >> n;
    while (n) {
        ans += (((n - 1) % 26) + 'a');
        n = (n - 1) / 26;
    }
    for (i=0; i<ans.size(); i++){
        cout << ans[ans.size()-i-1];
    }
    cout << endl;
}


Measured memory_bytes: 3604
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author rahdirigs
 */

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

template <typename T> void sub(T& a, T b, int mod) {
	a -= b;
	if (a < 0)
		a += mod;
}

template <typename T> void mul(T& a, T b, int mod) {
	a = a * b % mod;
}

ll power_mod(ll x, ll y, int mod) {
	ll ret = 1;
	while (y) {
		if (y & 1) mul(ret, x, mod);
		mul(x, x, mod);
		y = y >> 1;
	}
	return ret;
}

ll inverse_mod(ll x, int mod) {
	return power_mod(x, mod - 2, mod);
}

ll nCr(ll n, ll r, vector<ll>& fac, vector<ll>& inv, int mod) {
	ll ret = 0;
	if (n >= 0 && r >= 0 && n >= r)
		ret = fac[n] * inv[n - r] % mod * inv[r] % mod;
	return ret;
}

const int mod = 1e9 + 7;

class TaskY {
public:
	int H, W, N;
	static const int mxF = 2e5 + 5;
	vector<pair<int, int>> p;
	vector<ll> fac, inv;

	void solve(std::istream& in, std::ostream& out) {
		in >> H >> W >> N;
		p.emplace_back(1, 1);
		for (int i = 0; i < N; i++) {
			int r, c;
			in >> r >> c;
			p.emplace_back(r, c);
		}
		p.emplace_back(H, W);
		N += 2;
		sort(p.begin(), p.end(), comp);
		vector<ll> dp(N, 0);
		dp[0] = 1;
		fac.resize(mxF, 0), inv.resize(mxF);
		pre_process();
		for (int i = 1; i < N; i++) {
			dp[i] = func(p[i].first - 1, p[i].second - 1);
			for (int j = 1; j < i; j++) {
				if (p[i].first >= p[j].first && p[i].second >= p[j].second) {
					sub(dp[i], func(p[i].first - p[j].first, p[i].second - p[j].second) * dp[j] % mod, mod);
				}
			}
		}
		out << dp[N - 1];
	}

	static bool comp(const pair<int, int>& a, const pair<int, int>& b) {
		return (a.first + a.second) < (b.first + b.second);
	}

	void pre_process() {
		fac[0] = inv[0] = 1;
		for (int i = 1; i < mxF; i++) {
			fac[i] = fac[i - 1] * i % mod;
			inv[i] = inverse_mod(fac[i], mod);
		}
	}

	ll func(ll x, ll y) {
		return nCr(x + y, x, fac, inv, mod);
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	TaskY solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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


int main() {

  ll A,B;
  cin >> A >> B;
  if (A- 2*B>=0) cout << A-2*B << endl;
  else cout << 0 << endl;

  return 0;
}

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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1e9+7;
const int INF = 1<<18;
const lint INFLINT = 1LL<<60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) s.begin(), s.end()
#define SZ(s) s.size()

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

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a;
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

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



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n;
ll a[200010];
ll m1[200010],m2[200010];
int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	m1[0]=a[0];
	rep(i,1,n)m1[i]=max(m1[i-1],a[i]);
	m2[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--)m2[i]=max(m2[i+1],a[i]);
	rep(i,0,n){
		ll ans=0;
		if(i)ans=max(ans,m1[i-1]);
		ans=max(ans,m2[i+1]);
		printf("%lld\n",ans);
	}
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	string s; cin >> s;
	cout << (s == "ABC" ? "ARC" : "ABC") << endl;
}


Measured memory_bytes: 3612
#include<stdio.h>
int main(void){
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if (x>=r && W-x>=r && y>=r && H-y>=r){
	printf("Yes\n");
}
else{
	printf("No\n");
}
return 0;
}

Measured memory_bytes: 584
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]

for k in range(n):
    for i in range(n):
        for j in range(n):
            if a[i][j] > a[i][k]+a[k][j]:
                print(-1)
                exit(0)

ans = 0
for i in range(n):
    for j in range(i+1, n):
        ok = True
        for k in range(n):
            if i == k or j == k:
                continue
            if a[i][j] == a[i][k]+a[k][j]:
                ok = False
                break
        if ok:
            ans += a[i][j]
print(ans)


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

int main() {
  string S;
  cin >> S;
  int count = 0;
  if(S.at(0) != S.at(1)) {
    count++;
    if(S.at(1) != S.at(2)) {
      count++;
      if(S.at(2) != S.at(3)) {
        count++;
        cout << "Good" << endl;
      }
    }
  }
  if(count != 3) {
    cout << "Bad" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int r1 = a * b;
    int r2 = c * d;

    if(r1>=r2){
        cout<<r1;
    }
    else{
        cout<<r2;
    }
}


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

int main() {
	int h, w;
	cin >> h >> w;
	char grid[51][51];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> grid[i][j];
		}
	}
	for (int i = 1; i < h-1; i++) {
		for (int j = 1; j < w-1; j++) {
			if (grid[i][j] == '#') {
				if(grid[i-1][j]=='.'){
					if (grid[i][j-1] == '.') {
						if (grid[i+1][j] == '.') {
							if (grid[i][j+1] == '.') {
								cout << "No" << endl;
								return 0;
							}
						}
					}
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
tailing = [input()]
heading = []
q_num = int(input())
is_reverse = False
for _ in range(q_num):
    query = [x for x in input().split()]
    if query[0] == '1':
        is_reverse = not is_reverse
    else:
        if (not is_reverse and query[1] == '2') or (is_reverse and query[1] == '1'):
            tailing.append(query[2])
        else:
            heading.append(query[2])
ans = ''.join(reversed(heading)) + ''.join(tailing)
print(ans if not is_reverse else ans[::-1])


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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7
using P = pair<ll, ll>;
struct Edge { ll to, cost; };


int N;
vector<vector<Edge>> edges;

vector<ll> dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>> pq;
	vector<ll> d(N, INFL);
	d[s] = 0;
	pq.push({ 0,s });

	while (!pq.empty()) {
		auto p = pq.top(); pq.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (auto e : edges[v]) {
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				pq.push({ d[e.to],e.to });
			}
		}
	}
	return d;
}


int main()
{
	cin >> N;
	edges.resize(N);
	REP(i, N - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		edges[a].push_back({ b,c });
		edges[b].push_back({ a,c });
	}
	auto d = dijkstra(0);
	REP(i, N)cout << d[i] % 2 << endl;
	return 0;
}


Measured memory_bytes: 8704
#include<stdio.h>
 
long long Merge(int A[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int i,j,k;
  int L[n1+1],R[n2+1];
  long long res=0;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=1000000001;
  R[n2]=1000000001;
   
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
      res+= (long long)n1- (long long)i;
    }
  }
  return res;
}
 
long long Merge_Sort(int A[],int left,int right){
  int mid;
  long long res=0;
  if(left+1<right){
    mid=(left+right)/2;
 
    res+=Merge_Sort(A,left,mid);
    res+=Merge_Sort(A,mid,right);
    res+=Merge(A,left,mid,right);
     
  }
  return res;
}
 
int main(){
  int i,n,S[200000];
  long long x;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&S[i]);
 
  x=Merge_Sort(S,0,n);
  printf("%ld\n",x);
  return 0;
}

Measured memory_bytes: 2156
INF = 10 ** 9 + 7

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
dp = [0] * (N + 1)
for i in range(M):
    dp[a[i]] = -1

dp[0] = 1
for i in range(1, N + 1):
    if dp[i] == -1: continue
    tmp = 0
    if dp[i - 1] != -1:
        tmp += dp[i - 1]
    if dp[i - 2] != -1 and i > 1:
        tmp += dp[i - 2]
    dp[i] = tmp % INF

print(dp[N])

Measured memory_bytes: 13640
length = int(input())
chars = list(input())

maxOfKinds = 0

index = 0

while(index != len(chars)):
    numOfEquals = 0
    for i in range(0, index + 1):
        isExisted = False
        for k in range(0, i):
            if chars[i] == chars[k]:
                isExisted = True
        if isExisted == True:
            continue
        for j in range(index + 1, len(chars)):
            if chars[i] == chars[j]:
                numOfEquals += 1
                break
    if maxOfKinds < numOfEquals:
        maxOfKinds = numOfEquals
    index += 1

print(maxOfKinds)

Measured memory_bytes: 3064