akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int W, H;
// dfs
// https://qiita.com/drken/items/4a7869c5e304883f539b
void dfs(vector<vector<int>> &g, int h, int w) {
	g[h][w] = 0;
	for(int dh = -1; dh <= 1; dh++) {
		for(int dw = -1; dw <= 1; dw++) {
			int next_h = h + dh;
			int next_w = w + dw;
			if(next_h < 0 || next_h >= H || next_w < 0 || next_w >= W) continue;
			if(g[next_h][next_w] == 0) continue;
			dfs(g, next_h, next_w);
		}
	}
}

int main() {
	while(1) {
		cin >> W >> H;
		if(W == 0 && H == 0) break;
		vector<vector<int>> c(H, vector<int>(W));
		rep(i, H) rep(j, W) {
			cin >> c[i][j];
		}
		int cnt = 0;
		rep(i, H) rep(j, W) {
			if(c[i][j] == 0) continue;
			dfs(c, i, j);
			cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 3372
fun main(args: Array<String>) {
    val (A, B, C) = readInputLine().split(" ").map { it.toInt() }
    
    val cnt = IntArray(11)
    
    cnt[A]++
    cnt[B]++
    cnt[C]++

    println(if (cnt[5] == 2 && cnt[7] == 1) "YES" else "NO")
}

fun readInputLine(): String {
    return readLine()!!
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

template <class T>
struct SegmentTree{
	std::vector<T> v;
	T def;
	int n;
	SegmentTree(int n_, T default_value): def(default_value){
		n = 1;
		while(n<n_) n <<= 1;
		v.assign(2*n-1, def);
	}
	template<class I>
	SegmentTree(I first, I last, T default_value): SegmentTree(last-first, default_value){
		copy(first, last, v.begin()+n-1);
		for(int i=n-2; i>=0; i--)
			v[i] = merge(v[2*i+1], v[2*i+2]);
	}
	SegmentTree(std::vector<T> initial_data, T default_value):
	SegmentTree(initial_data.begin(), initial_data.end(), default_value){}
	void update(int idx, T val){
		idx += n-1;
		v[idx] = val;
		while(idx > 0){
			idx = (idx-1)/2;
			v[idx] = merge(v[2*idx+1], v[2*idx+2]);
		}
	}
	T q(int a, int b, int k, int l, int r){
		if(a<=l&&r<=b) return v[k];
		if(b<=l||r<=a) return def;
		return merge(q(a, b, 2*k+1, l, (l+r)/2), q(a, b, 2*k+2, (l+r)/2, r));
	}
	T query(int a, int b){
		return q(a, b, 0, 0, n);
	}
	T merge(T left, T right);
};

// Example

template <typename T>
T SegmentTree<T>::merge(T a, T b){
	return std::max(a, b);
}

int _main(){
	using namespace std;
	vector<int> a = {4,2,2,1,5,9,10};
	SegmentTree<int> st(a.begin(), a.end(), 1<<20);
	assert((st.query(0, 4)==1));
	for(int i=0; i<10; i++){
		assert((st.query(i, i+1)==i<a.size()?a[i]:1<<20));
	}

	return 0;
}

int main() {
	ios_base::sync_with_stdio(false);
	int n; cin >> n;
	vector<string> s(n);
	for(int i=0; i<n; i++) cin >> s[i];

	vector<pair<int, int>> l, r;
	for(int i=0; i<n; i++){
		int x=0;
		int y=0;
		for(char c:s[i]){
			if(c=='(') x++;
			else x--;
			y=min(y, x);
		}
		if(x>=0) l.emplace_back(y, x);
		else r.emplace_back(y-x, -x);
	}

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

	int cl = 0;
	for(auto li: l){
		if(cl+li.first<0){
			cout << "No" << endl;
			return 0;
		}
		cl += li.second;
		if(cl<0){
			cout << "No" << endl;
			return 0;
		}
	}
	int cr = 0;
	for(auto ri: r){
		if(cr+ri.first<0){
			cout << "No" << endl;
			return 0;
		}
		cr += ri.second;
		if(cr<0){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << (cr==cl?"Yes":"No") << endl;

	return 0;
}


Measured memory_bytes: 42472
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#include<cctype>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

ll A,B,C,Ans;

int main(void) {
	cin >> A>>B>>C;


	ct(B+min(A+B+1,C));
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 



int main()
{ 
    int n;
    cin>>n;
    if(n==2){cout<<-1<<endl;}
    else{
        string temp4[4];
        temp4[0]="abaa";
        temp4[1]="abcc";
        temp4[2]="ccba";
        temp4[3]="aaba";
        string temp6[6];
        temp6[0]="aabbcc";
        temp6[1]="bbccaa";
        temp6[2]="acb...";
        temp6[3]="acb...";
        temp6[4]="...abc";
        temp6[5]="...abc";
        string temp3[3];
        temp3[0]="aab";
        temp3[1]="b.b";
        temp3[2]="baa";
        string temp7[7];
        temp7[0]="aab...a";
        temp7[1]="b.b...a";
        temp7[2]="baa...c";
        temp7[3]="...aabc";
        temp7[4]="...b.bd";
        temp7[5]="...baad";
        temp7[6]="aaccdd.";
        string temp5[5];
        temp5[0]="aabbc";
        temp5[1]=".ddac";
        temp5[2]="aa.ab";
        temp5[3]="b.b.b";
        temp5[4]="b.baa";
        int cnt=0;
        if(n==3){
            for(int i=0;i<3;i++){
                cout<<temp3[i]<<endl;
            }
            cnt=3;
        }
        else if(n==5){
            for(int i=0;i<5;i++){
                cout<<temp5[i]<<endl;
            }
            cnt=5;
        }
        else if(n==9){
            for(int i=0;i<3;i++){
                for(int k=0;k<3;k++){
                    for(int j=0;j<cnt;j++){cout<<'.';}
                    cout<<temp3[k];
                    for(int j=0;j<n-cnt-3;j++){cout<<'.';}
                    cout<<endl;
                }
                cnt=cnt+3;
            }
        }
        else if(n%2==1){
            cnt=cnt+7;
            for(int i=0;i<7;i++){
                cout<<temp7[i];
                for(int j=0;j<n-7;j++){
                    cout<<'.';
                }
                cout<<endl;
            }
        }
        if((n-cnt)%4==2){
            for(int i=0;i<6;i++){
                for(int j=0;j<cnt;j++){cout<<'.';}
                cout<<temp6[i];
                for(int j=0;j<n-cnt-6;j++){
                    cout<<'.';
                }
                cout<<endl;
            }
            cnt=cnt+6;
        }
        while(cnt<n){
            for(int i=0;i<4;i++){
                for(int j=0;j<cnt;j++){cout<<'.';}
                cout<<temp4[i];
                for(int j=0;j<n-cnt-4;j++){cout<<'.';}
                cout<<endl;
            }
            cnt=cnt+4;
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 101;

int A[N], cnt[N];

int main() {
  int n;
  S(n);
  int mx = 0;
  rep(i,1,n+1) {
    S(A[i]);
    mx = max(mx,A[i]);
    cnt[A[i]]++;
  }

  if(cnt[mx] < 2) {
    printf("Impossible\n");
    return 0;
  }

  int half = (mx + 1) / 2;
  if(mx & 1) {
    if(cnt[half] != 2) {
      printf("Impossible\n");
      return 0;
    }
  } else {
    if(cnt[half] != 1) {
      printf("Impossible\n");
      return 0;
    }
  }

  rep(i,half+1,mx) {
    if(cnt[i] < 2) {
      printf("Impossible\n");
      return 0;
    }
  }

  rep(i,1,n+1) {
    if(A[i] < half) {
      printf("Impossible\n");
      return 0;
    }
  }

  printf("Possible\n");

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int q;
  cin>>q;
  string a,b;
  int x[1001][1001];
  x[0][0]=0;
  for(int i=1;i<=1000;i++){
    x[0][i]=0;
    x[i][0]=0;
  }
  for(int i=0;i<q;i++){
    cin>>a>>b;
    for(int j=1;j<=b.size();j++){
      for(int l=1;l<=a.size();l++){
	if(a[l-1]==b[j-1]){
	  if(x[j-1][l-1]+1>x[j][l-1]){
	    x[j][l]=x[j-1][l-1]+1;
	  }else{
	    x[j][l]=x[j][l-1];
	  }
	}else{
	  if(x[j-1][l]>x[j][l-1]){
	    x[j][l]=x[j-1][l];
	  }else{
	    x[j][l]=x[j][l-1];
	  }
	}
      }
    }
    cout<<x[b.size()][a.size()]<<endl;
  }
  return(0);
}



Measured memory_bytes: 7100
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector> // vectorを使うためにインクルードする
using namespace std;

int main() {
	char a[50];
	scanf("%4s", a); 
	if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
}

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

bool solve() {
    int N; cin >> N;
    multiset<int> ms;
    rep(i, 0, 1 << N) {
        int s; cin >> s;
        ms.insert(s);
    }
    auto mx = ms.end();
    --mx;
    vector<int> used;
    used.push_back(*mx);
    ms.erase(mx);
    rep(loop, 0, N) {
        vector<int> add;
        sort(used.begin(), used.end(), greater<int>());
        for(auto u : used) {
            auto e = ms.lower_bound(u);
            if(e == ms.begin()) return false;
            --e;
            add.push_back(*e);
            ms.erase(e);
        }
        for(auto a : add) used.push_back(a);
    }
    return true;
}

int main() {
    cout << (solve() ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 13884
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<long long ,long long >
#define ppll pair < pll , pll >
//#define mod 1000000007
unsigned int bp(int n) // built_in_pop_count // 
{ 
    unsigned int count = 0; 
    while (n) { 
        n &= (n - 1); 
        count++; 
    } 
    return count; 
} 
int32_t main(){
    SPEED;
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] != t[i]) ans++;
    }
    cout << ans ;
}

Measured memory_bytes: 3796
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
m=n//2-1
if m>=0:
  for i in range(n-1,m,-1):
    b[i]=a[i]
for i in range(m,0,-1):
  x=n//(i+1)
  s=0
  for j in range(2,x+1):
    s+=b[(i+1)*j-1]
  if a[i]==0:
    b[i]=s%2
  else:
    b[i]=(s+1)%2
if a[0]==0:
  b[0]=sum(b)%2
else:
  b[0]=(sum(b)+1)%2
c=[]
for i in range(n):
  if b[i]==1:
    c.append(i+1)
print(len(c))
for i in c:
  print(i)

Measured memory_bytes: 12084
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<int>>A(H,vector<int>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>A[i][j];
    }
  }

  vector<tuple<int,int,int,int>>p;

  int cnt=0;
  int i=0,j=0;
  for(int r=0;r<H*W-1;r++){
    int a=i,b=j;//一筆書きの経路をa,b->c,dとする
    if(i%2!=0){
      if(j>0){j--;}
      else{i++;}
    }
    else{
      if(j<W-1){j++;}
      else{i++;}
    }
    int c=i,d=j;
    if(A[a][b]%2!=0){
      cnt++;A[a][b]--;A[c][d]++;
      p.push_back(make_tuple(a+1,b+1,c+1,d+1));
    }
  }
  cout<<cnt<<endl;
  for(auto k:p){
    int a,b,c,d;
    tie(a,b,c,d)=k;
    cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl; 
  }
  return 0;  
}

Measured memory_bytes: 6348
local n, m = io.read("*n", "*n", "*l")
local ac = {}
local wa = {}
for i = 1, n do
  ac[i] = false
  wa[i] = 0
end
for i = 1, m do
  local p, s = io.read():match("(%d+) (%w+)")
  p = tonumber(p)
  if s == "AC" then
    ac[p] = true
  else
    if not ac[p] then
      wa[p] = wa[p] + 1
    end
  end
end
local acc, wac = 0, 0
for i = 1, n do
  if ac[i] then
    acc = acc + 1
    wac = wac + wa[i]
  end
end
print(acc .. " " .. wac)


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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  if (a[0] != 0) {
    cout << -1 << '\n';
    return 0;
  }
  long long res = 0;
  for (int i = 0; i < n - 1; i++) {
    if (a[i + 1] - a[i] > 1) {
      cout << -1 << '\n';
      return 0;
    }
    if (a[i + 1] == a[i] + 1) continue;
    res += a[i];
  }
  res += a[n - 1];
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 1024
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
st1='U'*dy+'R'*dx
ts1='D'*dy+'L'*dx
st2='L'+'U'*(dy+1)+'R'*(dx+1)+'D'
ts2='R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print(st1+ts1+st2+ts2)

Measured memory_bytes: 3060
use std::collections::BTreeMap;

fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    handle.read_line(&mut buf).unwrap();
    let n: usize = buf.trim().parse().unwrap();
    buf.clear();
    handle.read_line(&mut buf).unwrap();
    let mut ls: Vec<isize> = buf
        .trim()
        .split_whitespace()
        .map(|a| a.parse().unwrap())
        .collect();

    let mut sums: Vec<isize> = Vec::with_capacity(n);
    let total: isize = ls.iter().fold(0, |a, b| {
        let sum = a + b;
        sums.push(sum);
        sum
    });
    sums.pop();
    let mut min_x = std::isize::MAX;
    for i in sums {
        if (total - 2 * i).abs() < min_x {
            min_x = (total - 2 * i).abs();
        }
    }
    println!("{}", min_x);
}


Measured memory_bytes: 11512
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  int N; std::cin >> N;
  std::vector<int> d(N);
  for(int i=0; i<N; i++) std::cin >> d[i];

  std::sort(d.begin(), d.end(), [] (int a, int b) { return a<b; });
  int x = N/2-1;
  std::cout << d[x+1]-d[x] << std::endl;

  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
typedef long long llong;
using namespace std;
const llong DIV = 1000000007;

llong mod_pow(llong m, llong n, llong mod =DIV) {
	if(n==0){return 1;}
	if (n == 1){return m;}

	llong ret = mod_pow(m, n/2, mod);
	ret = ret * ret % mod;
	
	if (n&1){ret = (ret*m)%mod;}

	return ret;
}

llong ncr(llong n,llong r, llong mod =DIV){
	r = min(r,n-r);
	llong ret = 1;
	for (int i = 1; i <= r; i++) {
		ret = ret * (n-i+1) % mod;
		ret = ret * mod_pow(i, mod-2) % mod;
	}
	return ret;
}

int main(){
  llong n,m,k;
  cin>>n>>m>>k;
  llong ans = 0;
  for(int d = 1;d<n;d++){
	  ans = (ans + d*(n-d)*m*m)%DIV;
  }
  for(int d = 1;d<m;d++){
	  ans = (ans + d*(m-d)*n*n)%DIV;
  }
  cout<<((ncr(n*m-2,k-2)*ans)%DIV)<<endl;
  return 0;
}

Measured memory_bytes: 256
def f(s):
  n=len(s)
  for i in range(int((n+1)/2)):
    if s[i]!=s[-(i+1)]: return False
  return True
S=input()
N=len(S)
if f(S) and f(S[0:int((N-1)/2)]) and f(S[int((N+3)/2)-1:N+1]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

signed main() {
  ll N;
  cin >> N;
  COUT(N * N * N);
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = cin.ReadIntArray(N);
          	Array.Sort(A);
            Array.Reverse(A);
            var Alice = A.Where((Value,Index)=>{
                return Index % 2 == 0;
            }).Sum();

            var Bob = A.Where((Value,Index)=>{
                return Index % 2 == 1;
            }).Sum();

            WriteLine(Alice - Bob);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> vp;
typedef pair<ll, ll> pi;
typedef set<ll> si;
typedef set<char> sc;
typedef set<double> sd;
typedef map<ll, ll> mi;
#define pb push_back
#define mp make_pair
#define FI first
#define SE second

int main()
{
    char a; cin >> a; ++a;
    cout << a << endl;

    return 0;
}



Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline())
S = sys.stdin.readline().strip()

ans = 0
for L in range(1, N):
	dp = [0]*N 
	for x in range(N - L):
		if S[x] == S[x+L]:
			if x==0: dp[x] += 1
			else: dp[x] = min(dp[x-1]+1, L)
			ans = max(ans, dp[x])
print(ans)

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

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

    std::unordered_map<int, int> m;
    int A;
    for (int i = 0; i < N; ++i) {
        std::cin >> A;
        if (m.count(A) == 0) {
            m[A] = 1;
        } else {
            m[A] = 1 - m[A];
        }
    }

    int cnt = 0;
    for (const auto& p : m) {
        if (p.second == 1) {
            ++cnt;
        }
    }
    
    std::printf("%d\n", cnt);

    return 0;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = 9223372036854775807;
    ans = (ll)min(ans, abs((a / 2) * b * c - b * c * (a - (a / 2))));
    ans = (ll)min(ans, abs((b / 2) * a * c - a * c * (b - (b / 2))));
    ans = (ll)min(ans, abs((c / 2) * b * a - b * a * (c - (c / 2))));
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;

int main() {
  //入力
  char s[10];
  scanf("%s", s);

  //計算・出力
  if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2])  printf("Yes\n");
  else if(s[0] == s[2] && s[1] == s[3] && s[0] != s[1])  printf("Yes\n");
  else if(s[0] == s[3] && s[1] == s[2] && s[0] != s[1])  printf("Yes\n");
  else  printf("No\n");
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, m, a[1005], b[1005], c[1005];
int g[105][105];

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

    rep(i, n) rep(j, n) g[i][j] = INF;
    rep(i, n) g[i][i] = 0;
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
        g[a[i]][b[i]] = g[b[i]][a[i]] = c[i];
    }

    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                chmin(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }

    int ans = 0;
    rep(i, m) {
        if (c[i] > g[a[i]][b[i]]) ans++;
    }
    cout << ans << endl;
}


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

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

	int h = S / 60 / 60;
	int m = (S - h * 60 * 60) / 60;
	int s = S - h * 60 * 60 - m * 60;

	cout << h << ":" << m << ":" << s << endl;

}



Measured memory_bytes: 3108
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        int X, Y;
        Scanner sc = new Scanner(System.in);
        X = sc.next().charAt(0);
        Y = sc.next().charAt(0);
        
        if(X < Y)
            System.out.println("<");
        else if(X > Y)
            System.out.println(">");
        else
            System.out.println("=");
    }
    
}

Measured memory_bytes: 20820
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
int R, C;
int sy, sx, gy, gx;
char maze[50][50];
int dis[50][50];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

/*int bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (int i = 0; i < 4; i++) {
			int ny = p.first + dy[i];
			int nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] != '#' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}*/

int main() {
	char C;
	cin >>C;
	C++;
	cout << C << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

    cout << ((k+1)/2) * (k/2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  int n = in();
  int m = in();
  cout << n * (n-1) / 2 + m * (m-1) / 2 << endl;
  return 0;
}


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

using namespace std;

const int MAXN = 1e5 + 5;
vector<int> v(MAXN);

main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
		a[i]++;
		v[a[i]]++;
		v[a[i] - 1]++;
		v[a[i] + 1]++;
	}
	int ans = v[0];
	for (int i = 0; i < MAXN; i++){
		ans = max(v[i], ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
// C - Colorful Leaderboard
#include <bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<(n);++i)

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

	map<int,int> C;//<rate,count>
	rp(i, N){
		int a; cin>>a;
		if(a<400) C[400]++;
		else if(a<800) C[800]++;
		else if(a<1200) C[1200]++;
		else if(a<1600) C[1600]++;
		else if(a<2000) C[2000]++;
		else if(a<2400) C[2400]++;
		else if(a<2800) C[2800]++;
		else if(a<3200) C[3200]++;
		else C[4801]++;
	}

	int maxR=0, maxC=0;
	for(auto e:C){
		int r,c; tie(r,c)=e;
		if(maxR < r){
			maxR = r;
			maxC = c;
		}
	}

	int n = C.size();
	if(maxR < 4801) printf("%d %d\n", n, n);
	else{
		if(n > 1) printf("%d %d\n", n-1, n-1+maxC);
		else printf("%d %d\n", 1, maxC);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define dl double
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define each(i, n) for(auto&& i: n)
#define co(n) cout << fixed << setprecision(n)

int main() {
  int N;
  dl a;
  cin >> N;
  if(N % 2 == 0) {
    
    a =(dl) (N / 2) / N;
  }
  else {
    a =(dl) (N / 2 + 1) / N;
  }
  co(7);
  cout << a << endl;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//16:35~
int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);ios::sync_with_stdio(false);
	string S;cin>>S;S+="UUU";
	int i;
	for(int i=0;i+1<S.size();i+=2){
		if(S[i]=='L'||S[i+1]=='R'){cout<<"No"<<endl;return 0;}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define FPEN2 freopen("out.txt", "w", stdout);
#else
#define FPEN
#define FPEN2
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  string s[10] = {"pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"};
  void solve() {
    int n;
    cin >> n;
    cout << s[n % 10] << '\n';
  }
} NSPACE;
int main() {
  FPEN;
  FPEN2;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}

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


template <typename T>
void cout_vector(vector<T> A){
    for (int i=0;i<A.size();i++){
        cout << A[i] << " ";  
    }
    cout << endl;
}







int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> S(M);
    vector<int> P(M);
    vector<int> K(M);
    int ans = 0;
    rep(i,M){
        int k;
        cin >> k;
        vector<int> s(k);
        rep(j,k) cin >> s[j];
        S[i] = s;
    }
    rep(i,M) cin >> P[i];
    for (int bit = 0 ; bit < (1 << N); bit++){
        bool flag = true;
        vector<int> True_switch;
        for (int i = 0; i < N; i++){
            if(bit & (1 << i)){
                True_switch.push_back(i+1);
            }
        }   
    //cout << "----------" << endl;
    //cout_vector(True_switch);
    int m = 0;
    rep(k,M){
        int on_count = 0;
        for (int s : S[k]){             
            for(int t : True_switch){
                if (s == t) on_count++;
            }
        }
        flag =  (on_count % 2 == P[k]);
        if (!(flag)) break;            
        m++;
    }
    (m == M) && (ans++);
    }
    cout << ans << endl;
    return 0;
}


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

const int N = 4e5 + 5;
typedef long long LL;

LL a[N], b[N], k;
int n, m, ans;

int main() {
	cin>>n>>m>>k;
	for(int i = 1; i <= n; i++) 
		cin>>a[i], a[i] += a[i - 1];
	for(int i = 1; i <= m; i++)
		cin>>b[i], b[i] += b[i - 1];
	for(int i = 0; i <= n && a[i] <= k; i++) {
		LL s = k - a[i];
		int l = 0, r = m;
		while(l < r) {
			int mid = (l + r + 1)>>1;
			if(b[mid] <= s) l = mid;
			else r = mid - 1;
		}
		ans = max(ans, i + l);
	}
	cout<<ans<<endl;

	return 0;
}

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

bool isPrim(int x) {
	if (x <= 2) return false;
	for (int i = 2; i < x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

int main() {
	int n, x;

	cin >> n;

	/*for (int i = 0; i < n; i++) {
		cin >> x;
		if (x <= 2) continue;
		for (int i = 2; i < x; i++) {
			if (x % i == 0) ;
		}
		count++;
		cout << x << " " << count << endl;
	}*/

	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> x;
		while (1) {
			count++;
			if (x < 2) {
				count--;
				break;
			}
			for (int j = 2; j*j <= x; j++) {
				if (x % j == 0) {
					count--;
					break;
				}
			}
			
			break;
		}
	}
	cout << count << endl;

	return 0;
}



Measured memory_bytes: 3100
S = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
H = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
C = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
D = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

n = int(input())

for i in range(n):
    x, y = input().split()
    if x == "S":
        S[int(y)-1] = 1
    elif x == "H":
        H[int(y)-1] = 1
    elif x == "C":
        C[int(y)-1] = 1
    elif x == "D":
        D[int(y)-1] = 1
    else:
        pass

for m, val in enumerate(S):
    if val == 0:
        print("S", m+1)
for j, val in enumerate(H):
    if val == 0:
        print("H", j+1)
for k, val in enumerate(C):
    if val == 0:
        print("C", k+1)
for l, val in enumerate(D):
    if val == 0:
        print("D", l+1)



Measured memory_bytes: 5620
n, y = [int(x) for x in input().split()]

for i in range(n + 1):
    for j in range(i, n + 1):
        m = i
        g = j - i
        s = n - j
        if y == m * 10000 + g * 5000 + s * 1000:
            print("{} {} {}".format(m, g, s))
            exit()

print("-1 -1 -1 ")


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>

#define _USE_MATH_DEFINES
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999;
#define atcoder 1000000007;

using namespace std;

int main() {
	
	int N, ans=0;
	cin >> N;

	ans += N * 800;
	ans -= N / 15 * 200;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <sstream>
using namespace std;

int main()
{
	string s;
	cin >> s;
  int i;
	for (i = 1; i < 4; i++) {
		if (s[i-1] == s[i]) {
			break;
		}
	}
	if (i == 4) {
		cout << "Good" << endl;
	}
	else {
		cout << "Bad" << endl;
	}
	return(0);
}





Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
char a;

while(1){
scanf("%c", &a);

if(a >= 'a' && a <= 'z'){
a = a - 32;
}else if(a >= 'A' && a <= 'Z'){
a = a + 32;
}




printf("%c", a);

if(a == '\n')
break;

}


return 0;

}




Measured memory_bytes: 2100
// D - Prediction and Restriction
#include <bits/stdc++.h>
using namespace std;

int main(){
	int ans=0,N,K,R,S,P; string T;
	cin>>N>>K>>R>>S>>P>>T;
	for(int k=0; k<K; k++)
		for(int i=k; i<N; i+=K)
			if(i>=K && T[i-K]==T[i]) T[i] = '-';
			else ans += T[i]=='r'?P:T[i]=='s'?R:S;
	cout<< ans <<endl;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define umap unordered_map
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n,k;
  cin>>n>>k;
 
  map<int,int> p;
  vector<int> q={};
  rep(i,k){
  int x;
  cin>>x;
  p[x]=1;
  }
  
  rep(i,10){
    if(!p.count(i)) q.pb(i);
  }
  
  deque<int> que;

  for(auto x : q) {
  que.pb(x);
  }
  
  // BFS 開始 (キューが空になるまで探索を行う)
  while (!que.empty()) {
    int v = que.front(); // キューから先頭頂点を取り出す
    que.pop_front();

    if(v>=n) {
      cout << v << endl;
      return 0; 
    }
    
    // 新たな白色頂点 nv について距離情報を更新してキューに追加する
    else{ 
      for(auto x : q) {
      que.pb(v*10+x);
      }
    }    
  }

}


Measured memory_bytes: 3872
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n)-1; i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define pb  push_back
#define eb  emplace_back

const int INF = 1<<28;
const int MOD = 1000000007;

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		//標準入力取得
		int num = sc.nextInt();
		int d[] = new int[num];
		for (int i = 0; i < num; i++) {
			d[i] = sc.nextInt();
		}

		int total = 0;
		for (int i = 0; i < num - 1; i++) {
			for (int j = i + 1; j < num; j++) {
				total = total + d[i] * d[j];
			}
		}
		System.out.println(total);

		sc.close();
	}
}


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

const int DIM = 1e2 + 5;

int mat[DIM][DIM];

int main( void ) {
    
    int n, m, u;
    cin >> n >> m >> u;
    
    for( int i = 1; i <= u; i ++ ) {
        int x, y, p;
        cin >> x >> y >> p;
        
        if( p == 1 ) {
            for( int i = 1; i <= x; i ++ )
                for( int j = 1; j <= m; j ++ )
                    mat[i][j] = 1;
        } else
        if( p == 2 ) {
            for( int i = x + 1; i <= n; i ++ )
                for( int j = 1; j <= m; j ++ )
                    mat[i][j] = 1;
        } else
        if( p == 3 ) {
            for( int i = 1; i <= n; i ++ )
                for( int j = 1; j <= y; j ++ )
                    mat[i][j] = 1;
        } else
        if( p == 4 ) {
            for( int i = 1; i <= n; i ++ )
                for( int j = y + 1; j <= m; j ++ )
                    mat[i][j] = 1;
        }
    }
    
    int ans = 0;
    for( int i = 1; i <= n; i ++ )
        for( int j = 1; j <= m; j ++ )
            ans += ( mat[i][j] == 0 );
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 100000;
int N;
ll x[MAX_N+1], y[MAX_N+1];
int a, b;
ll D;
bool rm[MAX_N+1];
set<pll> s1;
set<pll> s2;
vector<pll> v1;
vector<pll> v2;
map<pll, int> id;

int main() {
  cin >> N >> a >> b;
  for (int i = 1; i <= N; ++i) cin >> x[i] >> y[i];
  D = (abs(x[a]-x[b])+abs(y[a]-y[b]));

  for (int i = 1; i <= N; ++i) {
    int tx = x[i], ty = y[i];
    x[i] = tx - ty;
    y[i] = tx + ty;
  }


  for (int i = 1; i <= N; ++i) {
    s1.insert(pll(x[i], y[i]));
    s2.insert(pll(y[i], x[i]));
    id[pll(x[i], y[i])] = i;
  }

  queue<int> que;
  que.push(a);

  while (!que.empty()) {
    int v = que.front(); que.pop();
    if (rm[v]) {continue;}
    rm[v] = true;

    auto ite = s1.lower_bound(pll(x[v]-D, y[v]-D));

    while (ite != s1.end()) {
      if (ite->fi != x[v]-D || ite->sc > y[v]+D) break;
      pll tp = *ite;
      que.push(id[*ite]);
      s2.erase(pll(ite->sc, ite->fi));
      s1.erase(ite++);
    }

    ite = s1.lower_bound(pll(x[v]+D, y[v]-D));
    while (ite != s1.end()) {
      if (ite->fi != x[v]+D || ite->sc > y[v]+D) break;
      que.push(id[*ite]);
      s2.erase(pll(ite->sc, ite->fi));
      s1.erase(ite++);
    }

    ite = s2.upper_bound(pll(y[v]-D, x[v]-D));
    while (ite != s2.end()) {
      if (ite->fi != y[v]-D || ite->sc >= x[v]+D) break;
      que.push(id[pll(ite->sc, ite->fi)]);
      s1.erase(pll(ite->sc, ite->fi));
      s2.erase(ite++);
    }

    ite = s2.upper_bound(pll(y[v]+D, x[v]-D));
    while (ite != s2.end()) {
      if (ite->fi != y[v]+D || ite->sc >= x[v]+D) break;
      que.push(id[pll(ite->sc, ite->fi)]);
      s1.erase(pll(ite->sc, ite->fi));
      s2.erase(ite++);
    }

  }


  for (int i = 1; i <= N; ++i) {
    if (rm[i]) {
      v1.push_back(pll(x[i], y[i]));
      v2.push_back(pll(y[i], x[i]));
    }
  }

  sort(all(v1));
  sort(all(v2));

  ll ans = 0;
  for (int v = 1; v <= N; ++v) {
    if (rm[v]) {
      ans += upper_bound(all(v1), pll(x[v]-D, y[v]+D)) - lower_bound(all(v1), pll(x[v]-D, y[v]-D));

      ans += upper_bound(all(v1), pll(x[v]+D, y[v]+D)) - lower_bound(all(v1), pll(x[v]+D, y[v]-D));

      ans += lower_bound(all(v2), pll(y[v]+D, x[v]+D)) - upper_bound(all(v2), pll(y[v]+D, x[v]-D));

      ans += lower_bound(all(v2), pll(y[v]-D, x[v]+D)) - upper_bound(all(v2), pll(y[v]-D, x[v]-D));
    }
  }

  cout << ans / 2 << endl;

  return 0;
}



Measured memory_bytes: 24160
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  vi a(3); rep(i,3) cin >> a[i];
  sort(all(a));
  if(a[0] == a[1] || a[1] == a[2]){
    if(a[0] == a[2]) {
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<n;i+=2)
using namespace std;
int main(){
  long long n;cin>>n;
  long long ans=10000000000000;
  while(n>100){
    if(ans>abs(753-n%1000))ans=abs(n%1000-753);
    n/=10;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn main() {
    let stdin_ = std::io::stdin();
    let stdout_ = std::io::stdout();
    let mut stdin = stdin_.lock();
    let mut stdout = stdout_.lock();

    let mut buffer = String::new();
    stdin.read_line(&mut buffer).unwrap();
    let b = buffer.trim();

    let s0 = b
        .as_bytes()
        .iter()
        .zip(['0' as u8, '1' as u8].iter().cycle())
        .map(|(&c0, &c1)| if c0 == c1 { 0 } else { 1 })
        .sum::<u64>();
    let s1 = b
        .as_bytes()
        .iter()
        .zip(['1' as u8, '0' as u8].iter().cycle())
        .map(|(&c0, &c1)| if c0 == c1 { 0 } else { 1 })
        .sum::<u64>();
    let s = if s0 > s1 { s1 } else { s0 };

    write!(stdout, "{}\n", s).unwrap();
}


Measured memory_bytes: 4352