akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
using namespace std;
typedef vector<int> vi;
string board[265];

int main()
{
  int n;
  while(cin >> n && n)
    {
      int ans=-1;
      int wchain=0;
      int hchain=0;
      int schain=0;
      for(int i=0;i<n;i++)
	{
	  cin >> board[i];
	}
      for(int i=0;i<n;i++)
	{
	  wchain=0;
	  for(int j=0;j<n;j++)
	    {
	      if(board[i][j]=='1')
		{
		  wchain++;
		}
	      else
		{
		  ans=max(ans,wchain);
		  wchain=0;
		}
	    }
	  ans=max(ans,wchain);
	}
      for(int i=0;i<n;i++)
	{
	  hchain=0;
	  for(int j=0;j<n;j++)
	    {
	      if(board[j][i]=='1')
		{
		  hchain++;
		}
	      else
		{
		  ans=max(ans,hchain);
		  hchain=0;
		}
	    }
	   ans=max(ans,hchain);
	}
      for(int i=0;i<n;i++)
	{
	  schain=0;
	  int h=i,w=0;
	  if(board[h][w]=='1')
	    {
	      schain++;
	    }
	  else
	    {
	      ans=max(ans,schain);
	      schain=0;
	    }
	  while((h-1)>=0 && (w+1)<n)
	    {
	      h--;
	      w++;
	      if(board[h][w]=='1')
		{
		  schain++;
		}
	      else
		{
		  ans=max(ans,schain);
		  schain=0;
		}
	    }
	   ans=max(ans,schain);
	}
      for(int i=0;i<n;i++)
	{
	  schain=0;
	  int h=n-1,w=i;
	  if(board[h][w]=='1')
	    {
	      schain++;
	    }
	  else
	    {
	      ans=max(ans,schain);
	      schain=0;
	    }
	  while((h-1)>=0 && (w+1)<n)
	    {
	      h--;
	      w++;
	      if(board[h][w]=='1')
		{
		  schain++;
		}
	      else
		{
		  ans=max(ans,schain);
		  schain=0;
		}
	    }
	  ans=max(ans,schain);
	}


       for(int i=0;i<n;i++)
	{
	  schain=0;
	  int h=i,w=0;
	  if(board[h][w]=='1')
	    {
	      schain++;
	    }
	  else
	    {
	      ans=max(ans,schain);
	      schain=0;
	    }
	  while((h+1)<n && (w+1)<n)
	    {
	      h++;
	      w++;
	      if(board[h][w]=='1')
		{
		  schain++;
		}
	      else
		{
		  ans=max(ans,schain);
		  schain=0;
		}
	    }
	  ans=max(ans,schain);
	}
      for(int i=0;i<n;i++)
	{
	  schain=0;
	  int h=0,w=i;
	  if(board[h][w]=='1')
	    {
	      schain++;
	    }
	  else
	    {
	      ans=max(ans,schain);
	      schain=0;
	    }
	  while((h+1)<n && (w+1)<n)
	    {
	      h++;
	      w++;
	      if(board[h][w]=='1')
		{
		  schain++;
		}
	      else
		{
		  ans=max(ans,schain);
		  schain=0;
		}
	    }
	  ans=max(ans,schain);
	}
      cout << ans << endl;
    }
  return 0;
}



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

int main() {
    long n, ans = 0;
    cin >> n;
    map<int, long> mp;
    rep(i, n) {
        int a;
        cin >> a;
        if(i - a > 0 && mp.find(i - a) != mp.end()) ans += mp[i - a];
        mp[a + i]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15944
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int X,Y;
    int crane,turtle;
    
    cin >> X >> Y;
    
    bool can = false;
    
    for(int crane=0;crane<=X;){
        turtle = X - crane;
        int foot_sum = 2*crane + 4*turtle;
        if(foot_sum == Y){
            can = true;
        }
        if(can) break;
        if(!can) crane++;
    }

    
    if(can)cout << "Yes";
    else cout << "No";
    
}

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

int main() {
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++) {
		cin >> a[i];
	}
	sort(a,a+n);
	float ans=(a[0]+a[1])/2.0;
	for(int i=2;i<n;i++) {
		ans=(float)(a[i]+ans)/2.0;
//		cout <<ans << endl;
		
	}
	printf("%.5f",ans);
	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

double calc(int[][] a) {
    a.sort();
    double ans = 0;
    int n = 0;
    foreach (e; permutations(a)) {
        for (int i = 1; i < e.length; i++) {
            double x1 = e[i - 1][0];
            double y1 = e[i - 1][1];
            double x2 = e[i][0];
            double y2 = e[i][1];
            ans += sqrt((x1 - x2) ^^ 2 + (y1 - y2) ^^ 2);
        }
        n++;
    }
    return ans / n;
}

void main() {
    int n = readint;
    int[][] a;
    foreach (_; 0..n) {
        a ~= readints;
    }

    auto ans = calc(a);
    writefln("%.8f", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using iint = int;
using Pair = pair<int, int>;
using Vec = vector<ll>;
using Graph = vector<Vec>;

#define int ll

iint		main(void)
{
	int n;
	cin >> n;
	Vec a(n);
	Vec ball(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
		ball[a[i]]++;
	}
	Vec c(n);
	Vec c2(n);
	for (int i = 0; i < n; i++) {
		int tmp = ball[i];
		if (tmp < 2)
			continue ;
		c[i] = tmp * (tmp - 1) / 2;
		if (tmp >= 3)
			c2[i] = (tmp - 1) * (tmp - 2) / 2;
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += c[i];
	}
	for (int i = 0; i < n; i++) {
		int tmp = sum;
		tmp -= c[a[i]];
		tmp += c2[a[i]];
		cout << tmp << endl;
	}
}



Measured memory_bytes: 8832
// Hint: Don't look, No need, Let'em Play.

#include <bits/stdc++.h>
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test

void solve() {
    int n, ans = 0;
    cin >> n;

    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        ans += (x & 1) & (i & 1);
    }
    cout << ans << '\n';
}

signed main() {
    fast;
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    while (t--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3608
use std::io::{stdin, Read};


fn main() {
    let mut buffer = String::new();
    let mut stdin = stdin();

    stdin.read_to_string(&mut buffer).unwrap();
    let rows: Vec<&str> = buffer.split('\n').collect();
    let row1: Vec<&str> = rows[0].split(' ').collect();
    let h_1: u64 = row1[0].parse().unwrap();
    let m_1: u64 = row1[1].parse().unwrap();
    let h_2: u64 = row1[2].parse().unwrap();
    let m_2: u64 = row1[3].parse().unwrap();
    let k: u64 = row1[4].parse().unwrap();

    let t: u64 = (h_2 - h_1) * 60 + (m_2 - m_1) - k;

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

Measured memory_bytes: 2108
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int N; cin >> N;
  for (int i = 1; i <= 9; ++i) {
    int v = i*100 + i*10 + i;
    if (v >= N) {
      cout << v << endl;
      return 0;
    }
  }
}


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

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

const int NMAX = 100;
bool flag;

bool cmp(int x,int y){
    return abs(0-x)<abs(0-y);
}

bool even(vector<int> vec){
    bool ok=true;
    for(auto item:vec){
        if(item%2!=0){
            ok=false;
            break;
        }
    }
    return ok;
}

signed main(){
    CIN(N);
    vi v(N);
    rep(i,N) cin>>v[i];
    
    int ans=0;
    while(even(v)){
        RepA(v) item/=2;
        ans++;
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {


	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(in.hasNextLine()){
			String s = in.nextLine();
			int joi = 0, ioi = 0;
			for(int i=0; i<s.length()-2; i++)if(s.substring(i, i+3).equals("JOI")) joi++;
			for(int i=0; i<s.length()-2; i++)if(s.substring(i, i+3).equals("IOI")) ioi++;
			System.out.println(joi);
			System.out.println(ioi);
		}
	}

}

Measured memory_bytes: 12000
#include <stdio.h>
#include <ctype.h>

int main() {
    char a[1200];
    fgets(a, 1200, stdin);
    for (int i=0; a[i]!='\n'; i++) {
        if (isupper(a[i])) {
            a[i] = tolower(a[i]);
        } else if (islower(a[i])) {
            a[i] = toupper(a[i]);
        }
        printf("%c", a[i]);
    }
    putchar('\n');
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int x, y;
  cin >> x >> y;
  int kame2 = (y - 2 * x);
  if (kame2 < 0) {
    cout << "No" << endl;
    return 0;
  }
  if (kame2%2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  if (kame2/2 <= x) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  printf("%s\n",(a==5&&b==5&&c==7)||(a==5&&b==7&&c==5)||(a==7&&b==5&&c==5)?"YES":"NO");
  return 0;
}

Measured memory_bytes: 128
from collections import deque
N, M = map(int, input().split())
X = [[] for i in range(N)] # iからの行き先
Y = [0 for i in range(N)] # iに来る辺の数
dp = [0 for i in range(N)] # iで終わる最長経路の長さ

for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    X[x].append(y)
    Y[y] += 1


Q = deque([])
for i in range(N):
    if Y[i] == 0:
        Q.append(i)

while len(Q) > 0:
    i = Q.popleft()
    for x in X[i]:
        dp[x] = max(dp[x], dp[i] + 1)
        Y[x] -= 1
        if Y[x] == 0:
            Q.append(x)

print(max(dp))

Measured memory_bytes: 60976
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}


int main(){
    
    fastio;

    int N; 
    cin >> N;

    string s;
    cin >> s;

    int nr = 0, ng = 0, nb = 0;
    rep(i, N){
        if(s[i] == 'B') nb++;
        else if(s[i] == 'G') ng++;
        else nr++;
    }

    lli res = (lli) nr * ng * nb;
    repA(len, 1, N){
        for(int i = 0; i + 2 * len < N; i++){
            if(s[i] == s[i + len] || s[i] == s[i + 2*len] || s[i + len] == s[i + 2 * len]){
                continue;
            }else{
                res--;
            }
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#define ff first
#define ss second
#define M 1000000007
typedef long long int ll;
using namespace std;
vector <vector <ll>> adj;
vector <bool> visited;
ll power(ll a,ll b){
    ll ans = 1;
    while(b>0){
        if(b%2!=0){
            ans = ((ans)*(a));
        }
        a = ((a)*(a));
        b=b/2;
    }
    return ans;
}
void dfs(ll u,vector <ll> &dp){
    visited[u]=true;
    for(auto i:adj[u]){
        if(!visited[i]){
            dfs(i,dp);
        }
        dp[u]=max(dp[u],1+dp[i]);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vector <ll> dp(n+1,0);
    visited.assign(n+1,false);
    adj.assign(n+1,vector <ll> ());
    for(ll i=0;i<m;i++){
        ll u,v;
        cin>>u>>v;
        adj[u].push_back(v);
    }
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        if(!visited[i]){
            dfs(i,dp);
        }
    }
    for(ll i=1;i<=n;i++){
        ans=max(dp[i],ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9216
arr = list(input())
z = 1
result = 1
count = 0
for i in range(len(arr) - 1):
    if arr[i] == arr[i+1] == "R":
        z += 1
        result = max(result, z)
    else:
        z = 1
if set(arr) == {'S'}:
    print(0)
else:
    print(result)



Measured memory_bytes: 9020
def ABS(N, Z, W, ai):
    if len(ai) == 1:
        return abs(ai[0]-W)
    else:
        return max(abs(ai[-1]-W), abs(ai[-1]-ai[-2]))


if __name__ == '__main__':
    n, z, w = [int(i) for i in input().split()]
    ai = list(map(int, input().split()))
    print(ABS(n, z, w, ai))

Measured memory_bytes: 3188
#include<iostream>
#include<map>
#include<cstring>
#include<vector>
using namespace std ;
typedef long long ll ;
map < ll,ll > mp ;
vector < ll > used(200005,-1);
int main ()
{
    ll n,k;
    cin >> n >> k ;
    for(int i=1;i<=n;i++)
    {
        ll x ;
        cin >> x ;
        mp[i]=x;
    }
    ll s =min(n,k),p=0,q=1,saved=0,d=0;
    used[1]=0;
    while(s--)
    {
        p++;
        if(used[mp[q]]!=-1)
        {
            d = p - used[mp[q]];
            saved=mp[q];
            break;
        }
        else
        {
            q=mp[q];
            used[q]=p;
        }
    }
  //  cout << saved << " "<< d << " " << k << endl;
    if(saved==0){saved=q;}
    if(p<k)
    {
        k = k - p ;
        k = k%d ;
        while(k--)
        {
            saved=mp[saved];
        }
    }
    cout << saved << endl;
    return 0 ;
}

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

int main(){
  int A, B, c, count=0;
  int  a_num, b_num, d_num, e_num;
  cin >> A >> B;
  for (int i = A; i<=B; i++){
    c = i;
    e_num = c % 10; //1
    c = (c - e_num) / 10;
    d_num = c % 10; //2
    c = (c - d_num) / 10;
    c = (c - c%10) / 10;
    b_num = c % 10; //4
    c = (c - b_num) / 10;
    a_num = c % 10; //5
    if (a_num == e_num && b_num == d_num) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	n := readInt()

	fmt.Println(3 * n * n)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#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 2e9
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
using namespace std;
typedef long long ll;
int main(){
   int n,c[10][10],s;
  FILL2D(c,0);
   cin>>n;
   FOR(i,1,n+1){
       int k=i;
       while(k>9){
           k/=10;
       }
       c[k][i%10]++;
   }
   s=0;
   REP(i,10){
       REP(j,10){
           s+=c[i][j]*c[j][i];
       }
   }
   cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using ll = long long;

std::vector<int> A(10);
std::vector<std::vector<int>> R;
int res{0};

int calc() {
  int p{0};
  for (auto&& S : R) {
    if (A[S[1] - 1] - A[S[0] - 1] == S[2]) p += S[3];
  }
  return p;
}

int max(int x, int y) { return (x > y) ? x : y; };

void dfs(int i, int n, int low, int high) {
  if (i == n) {
    // for (int i = 0; i < n; i++) std::cout << A[i] << ' ';
    res = max(res, calc());
  } else {
    for (int j = low; j <= high; j++) {
      A[i] = j;
      dfs(i + 1, n, j, high);
    }
  }
}

int main() {
  int N, M, Q;
  std::cin >> N >> M >> Q;
  R.resize(Q);
  for (int i = 0; i < Q; i++) {
    R[i].resize(4);
    for (int j = 0; j < 4; j++) std::cin >> R[i][j];
  }
  dfs(0, N, 1, M);
  std::cout << res << std::endl;
  return 0;
}

Measured memory_bytes: 3532
#include <iostream>

using namespace std;

int main()
{
    char ch;
    cin >> ch;
    if (ch == 'A') cout << 'T';
    else if (ch == 'T') cout << 'A';
    else if (ch == 'C') cout << 'G';
    else if (ch == 'G') cout << 'C';
}

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

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

int main() {
  Bint N,K;
  cin>>N>>K;
  Bint a=N/K,b=(N+K/2)/K;
  Bint ans=a*a*a;
  if(K%2==0){
    ans+=b*b*b;
  }
  cout<<ans;
  

 
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    vector<int> count(N);

    for (int i = 0; i < N; i++) {
        cin >> H.at(i);
        count.at(i) = 0;
    }

    count.at(N - 1) = 0;
    int max = 0;
    for (int i = N - 1; i > 0; i--) {
        if (H.at(i - 1) < H.at(i)) {
            count.at(i - 1) = 0;
        } else {
            count.at(i - 1) = count.at(i) + 1;
        }
        if (count.at(i - 1) >= max) {
            max = count.at(i - 1);
        }
    }

    cout << max << endl;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    s=[[]]*M
    for i in range(M):
        l=list(map(int,input().split()))
        s[i]=list(map(lambda x: x-1, l[1:]))
    p=list(map(int,input().split()))
    ans=0
    for i in range(2**N):
        c = [0]*M
        for j in range(N):
            if (i >> j) & 0b1 == 1:
                for light_num in range(M):
                    if j in s[light_num]:
                        c[light_num]+=1
        for light_num in range(M):
            if p[light_num] == c[light_num]%2:
                pass
            else:
                break
        else:
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 44016
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int dp[5050][5050];

signed main(){
  int n;
  string s;
  cin >> n >> s;
  rrep(i,n-1,0){
    rrep(j,n-1,0){
      if(s[i] != s[j]) dp[i][j] = 0;
      else{
        dp[i][j] = dp[i+1][j+1]+1;
      }
    }
  }
  int ans = 0;
  rep(i,0,n){
    rep(j,0,n){
      if(j < i) continue;
      int n = min(dp[i][j],j-i);
      ans = max(ans,n);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 198912
#include <iostream>
#include <algorithm>

using namespace std;

#define ll long long
ll extgcd(ll a,ll b,ll &x,ll &y){
	ll g=a; x=1; y=0;
	if(b)g=extgcd(b,a%b,y,x), y-=a/b*x;
	return g;
}
ll inv(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (x%m+m)%m;
}

const int m1=999979,m2=999983;

int main(){
	int n,o,y;
	ll a=0,b=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>o>>y;
		if(o==1)a=(a+y)%m1, b=(b+y)%m2;
		if(o==2)a=(a-y%m1+m1)%m1, b=(b-y%m2+m2)%m2;
		if(o==3)a=(a*y)%m1, b=(b*y)%m2;
		if(o==4)a=(a*inv(y,m1))%m1, b=(b*inv(y,m2))%m2;
	}
	ll p,q;
	extgcd(m1,m2,p,q);
	ll ans=(b*m1*p+a*m2*q)%((ll)m1*m2);
	if(ans>=1ll<<31)ans-=(ll)m1*m2;
	cout<<ans<<endl;
	return 0;
}

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

#define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to)
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define File(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define fi first
#define se second
#define pb push_back

template<typename A, typename B> inline char smax(A &a, const B &b) {return a < b ? a = b , 1 : 0;}
template<typename A, typename B> inline char smin(A &a, const B &b) {return b < a ? a = b , 1 : 0;}

typedef long long ll; typedef unsigned long long ull; typedef std::pair<int, int> pii;

template<typename I>
inline void read(I &x) {
	int f = 0, c;
	while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
	x = c & 15;
	while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
	f ? x = -x : 0;
}

const int N = 2e5 + 7;

int n, m;
std::vector<int> a[N];

namespace SGT {
	#define lc o << 1
	#define rc o << 1 | 1
	struct Node {int add, max;} t[N << 2];
	int a[N];
	inline void build(int o, int L, int R) {
		// dbg("build: o = %d, L = %d, R = %d\n", o, L, R);
		t[o].add = 0;
		if (L == R) return (void)(t[o].max = a[L]);
		int M = (L + R) >> 1;
		build(lc, L, M); build(rc, M + 1, R);
		t[o].max = std::max(t[lc].max, t[rc].max);
	}
	inline void pushdown(int o) {
		if (!t[o].add) return;
		t[lc].add += t[o].add, t[lc].max += t[o].add;
		t[rc].add += t[o].add, t[rc].max += t[o].add;
		t[o].add = 0;
	}
	inline void pushup(int o) {
		t[o].max = std::max(t[lc].max, t[rc].max);
		t[o].max += t[o].add;
	}
	inline void qadd(int o, int L, int R, int l, int r, int k) {
		if (l <= L && R <= r) return (void)(t[o].add += k, t[o].max += k);
		int M = (L + R) >> 1;
		pushdown(o);
		if (l <= M) qadd(lc, L, M, l, r, k);
		if (r > M) qadd(rc, M + 1, R, l, r, k);
		pushup(o);
	}
	inline int qmax(int o, int L, int R, int l, int r) {
		if (l > r) return 0;
		// dbg("o = %d, L = %d, R = %d, l = %d, r = %d\n", o, L, R, l, r);
		if (l <= L && R <= r) return t[o].max;
		int M = (L + R) >> 1;
		pushdown(o);
		if (r <= M) return qmax(lc, L, M, l, r);
		if (l > M) return qmax(rc, M + 1, R, l, r);
		return std::max(qmax(lc, L, M, l, r), qmax(rc, M + 1, R, l, r));
	}
}
using SGT::build;
using SGT::qadd;
using SGT::qmax;

inline void work() {
	++n;
	for (int i = 0; i <= n; ++i) SGT::a[i] = i - n;
	build(1, 0, n);
	int ans = std::max(0, m - n + 1);
	for (int i = 0; i <= n; ++i) {
		for (auto j : a[i]) qadd(1, 0, n, 0, j, 1);//, dbg("********* add: i = %d, j = %d\n", i, j);
		smax(ans, qmax(1, 0, n, i + 1, n) - i);
		// dbg("i = %d, ans = %d, hkk = %d\n", i, ans, qmax(1, 0, n, i, n));
	}
	printf("%d\n", ans);
}

inline void init() {
	read(m), read(n);
	for (int i = 1; i <= m; ++i) {
		int l, r;
		read(l), read(r);
		a[l].pb(r);
	}
}

int main() {
	#ifdef hzhkk
	freopen("hkk.in", "r", stdin);
	#endif
	init();
	work();
	fclose(stdin), fclose(stdout);
	return 0;
}

Measured memory_bytes: 15488
N, K = map(int, input().split())
S = N * (N+1) // 2

A = [0 for _ in range(N+1)]
for i in range(1, N+1):
    A[i] = i * (i+1) // 2

ans = 0
for j in range(K, N+2):
    minSum = j * (j-1) // 2
    maxSum = S - (N-j)*(N-j+1)//2
    possibleSums = maxSum - minSum + 1
    ans += possibleSums % (10**9 + 7)
ans %= (10**9 + 7)
print(ans)


Measured memory_bytes: 79580
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int a,b;
    cin >> a >> b;
    if((a%2)*(b%2)==1){
        cout << "Odd" << endl;
    }
    else{
        cout << "Even" << endl;
    }
    return 0;
}



Measured memory_bytes: 764
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n = i_input()
    num_list = i_list()

    hifu_count = 0
    zero_count = num_list.count(0)

    for num in num_list:
        if num < 0:
            hifu_count += 1

    count = 0
    for num in num_list:
        count += abs(num)

    if zero_count >= 1 or hifu_count % 2 == 0:
        pass
    else:
        min_num = INF
        for num in num_list:
            min_num = min(min_num, abs(num))
        count -= min_num * 2
        
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 85356
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,k,s;
	cin>>n>>k>>s;
	int dm = 1000000000;
	if( s == dm ) dm--;
	for(int i=0; i<k; i++ ){
		cout<< s << " ";
	}
	for(int i=k; i<n;i++){
		cout<< dm << " ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1280
import itertools

N = int(input())

dic = {"M":{},"A":{},"R":{},"C":{},"H":{}}

for i in range(0,N,1):
    s = input()
    if s[0] in dic:
        dic[s[0]][s]=0

ans = 0
for i in itertools.combinations(["M","A","R","C","H"],3):
    ans+= len(dic[i[0]])*len(dic[i[1]])*len(dic[i[2]])

print(ans)

Measured memory_bytes: 98772
N = int(input())
A = list(map(int,input().split()))
cnt1 = 0
cnt2 = 0
for i in range(N):
    if A[i]%2 == 0:
        cnt1 += 1
        if A[i]%3 == 0 or A[i]%5 == 0:
            cnt2 += 1
if cnt1 == cnt2:
     print("APPROVED")
else:
    print("DENIED")

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  ll H, W; scanf("%lld %lld", &H, &W);
  if (H % 3 == 0 or W % 3 == 0) {
    printf("0\n");
    return 0;
  }
  if (H > W) { swap(H, W); }
  ll a, b, c;
  ll ans = INF;
  for (int i = 1; i <= (W + 1) / 2; ++i) {
    ll ww = W - i;
    a = H * i;
    b = (H / 2) * ww;
    c = (H - (H / 2)) * ww;
    ll diff = max(a, max(b, c)) - min(a, min(b, c));
    ans = min(ans, diff);
    b = H * (ww / 2);
    c = H * (ww - (ww / 2));
    diff = max(a, max(b, c)) - min(a, min(b, c));
    ans = min(ans, diff);
  }
  for (int i = 1; i <= (H + 1) / 2; ++i) {
    ll hh = H - i;
    a = i * W;
    b = hh * (W / 2);
    c = hh * (W - (W / 2));
    ll diff = max(a, max(b, c)) - min(a, min(b, c));
    ans = min(ans, diff);
    b = W * (hh / 2);
    c = W * (hh - (hh / 2));
    diff = max(a, max(b, c)) - min(a, min(b, c));
    ans = min(ans, diff);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#include <cstdint>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

std::vector<std::pair<long, long> > prime_factorize(long n){//first^second
    std::vector<std::pair<long, long> > ret;
    if(n < 2){
        printf("prime_factorize input invalid!\n");
        return ret;
    }
    for(long div = 2; div * div <= n; div++){
        std::pair<long, long> p(div, 0);
        while(n % div == 0){
            n /= div;
            p.second++;
        }
        if(p.second){
            ret.push_back(p);
        }
    }
    if(n != 1){
        ret.push_back(std::pair<long, long>(n, 1));
    }
    return ret;
}

long n;

typedef std::pair<long, long> P;

int main(){
    scanf("%ld", &n);
    if(n == 1){
        printf("0\n");
        return 0;
    }
    std::vector<P> pr = prime_factorize(n);
    long ans = 0;
    for(int i = 0; i < pr.size(); i++){
        long x;
        for(x=1; x * (x+1)/2 <= pr[i].second; x++);
        ans += x-1;
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

void warshall(vector<vector<int> > &adj){
	int n = adj[0].size();
	for(int k=0; k<n; k++){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);
			}
		}
	}
}

int main(){
	while(1){
		int n,m;
		cin >> n >> m;
		if(n==0) break;
		
		vector<vector<int> > adjc(m+1, vector<int>(m+1, inf));
		vector<vector<int> > adjt(m+1, vector<int>(m+1, inf));
		for(int i=0; i<n; i++){
			int a,b,c,t;
			cin >> a >> b >> c >> t;
			adjc[a][b] = adjc[b][a] = c;
			adjt[a][b] = adjt[b][a] = t;
		}
		warshall(adjc);
		warshall(adjt);
		
		int k;
		cin >> k;
		for(int i=0; i<k; i++){
			int p,q,r;
			cin >> p >> q >> r;
			if(r==0){
				cout << adjc[p][q] << endl;
			}else{
				cout << adjt[p][q] << endl;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3232
package main

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

func main() {
	io, flush := NewIO()
	defer flush()

	n, d := io.ScanInt2()
	var count int
	for i := 0; i < n; i++ {
		x, y := io.ScanInt2()
		if math.Sqrt(float64(x*x+y*y)) <= float64(d){
			count++
		}
	}
	fmt.Println(count)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 7952
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

int cnt[100];

void input(){
	int N;
	scanf("%d", &N);
	for(int i = 0; i < N; ++i){
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
}

int calc(int mask){
	vector<int> vec;
	vec.push_back(0);
	if(cnt[0] > 0) return 0;
	mask <<= 1;
	for(int i = 1; i <= 12; ++i){
		if(cnt[i] > 2) return 0;
		if(cnt[i] == 2){
			vec.push_back(i);
			vec.push_back(-i);
		}
		if(cnt[i] == 1){
			if((mask >> i) & 1){
				vec.push_back(i);
			}else{
				vec.push_back(-i);
			}
		}
	}
	sort(vec.begin(), vec.end());
	int x = 100;
	for(int i = 0; i + 1 < vec.size(); ++i){
		x = min(x, vec[i + 1] - vec[i]);
	}
	x = min(x, vec[0] + 24 - vec[vec.size() - 1]);
/*	if(x == 5){
		for(int i = 0; i < vec.size(); ++i){
			printf("%d ", vec[i]);
		}
		printf("\n");
	}*/
	return x;
}

int solve(){
	int x = 0;
	for(int i = 0; i < (1 << 12); ++i){
		int tmp = calc(i);
		x = max(x, tmp);
	}
	return x;
}

int main(){
	input();
	int ans = solve();
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
long long a[100100];int k,cnt=0;
int main()
{
	scanf("%d",&k);for(int i=1;i<=k;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=k;i++)if(a[i]!=1)a[++cnt]=a[i];k=cnt;
	if(a[k]!=2)return 0*puts("-1");long long ans1=2,ans2=2;
	for(int i=k;i>=2;i--)
	{
		ans1=(((ans1-1)/a[i-1])+1)*a[i-1];
		ans2=(ans2+a[i]-1)/a[i-1]*a[i-1];
		if(ans1>ans2)return 0*puts("-1");
	}
	printf("%lld %lld",ans1,ans2+a[1]-1);return 0;
 } 

Measured memory_bytes: 1024
/*
时间:2020-7-28
书籍：算法和数据结构
内容：栈
页数：P59
*/
#include<iostream>
#include<stdlib.h>
using namespace std;
int S[100];
int top = -1;
int main()
{
	string str;
	while (true)
	{
		cin >> str;
		if (str == "+")
		{
			int a = S[top--];
			int b = S[top--];
			S[++top] = a + b;
		}
		else if(str=="-")
		{
			int a = S[top--];
			int b = S[top--];
			S[++top] = b-a;
		}
		else if (str == "*")
		{
			int a = S[top--];
			int b = S[top--];
			S[++top] = b * a;
		}
		else
		{
			S[++top] = atoi(str.c_str());
		}
		if (cin.get() == '\n')
			break;
	}
	cout << S[top]<<endl;
	return 0;
}


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

int main(){
	//cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int>a(n);
	unordered_map<int,int>m;
	for(auto&i:a){
		cin>>i;
		++m[i];
	}
	int64_t ans=0,tmp,tmp2;
	for(auto&i:m)ans+=(int64_t)i.second*(i.second-1)/2;
	for(auto&i:a){
		tmp=m.at(i);
		tmp=tmp*(tmp-1)/2;
		tmp2=m.at(i)-1;
		tmp2=tmp2*(tmp2-1)/2;
		cout<<ans-tmp+tmp2<<"\n"s;
	}
}

Measured memory_bytes: 8392
#include<cstdio>
long long N,X;
long long F(long long A,long long B){
	if(A%B==0) return A+A-B;
	return A/B*B*2+F(B,A%B);
}
int main(){
	scanf("%lld%lld",&N,&X);
	printf("%lld",N+F(N-X,X));
	return 0;
}

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

int main()
{
  int nmembers, nfood;
  std::cin >> nmembers >> nfood;
  std::vector<int> food(nfood, 0);
  for (int x = 0; x < nmembers; x++) {
    int k;
    std::cin >> k;
    for (int y = 0; y < k; y++) {
      int food_id;
      std::cin >> food_id;
      food.at(food_id-1)++;
    }
  }
  int cnt = 0;
  for (int i = 0; i < nfood; i++) {
    if (food.at(i) == nmembers) {
      cnt++;
    }
  }
  std::cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <sstream>
#include <bitset>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define MOD ((int)1e9+7)
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

struct Combination {
	const int num=51e4;			//要素数
	const int mod=1e9+7;
	vector<ll> fact,inv,finv; //階乗,逆元,逆元の階乗.
	
	Combination():fact(num),inv(num),finv(num){
		fact[0]=fact[1]=1;
		inv[1]=1;
		finv[0]=finv[1]=1;
		for(int i=2;i<num;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){
		if(n<k) return 0;
		if(n<0 or k<0) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	int big_nCk(int n,int k){ //nが大きいとき
		ll res=1LL;
		for (int i = 0; i < k; i++) {
			res=res*(n-i)%mod;
		}
		res = res*finv[k]%mod;
		return res;
	}
	int nHk(int n,int k){return nCk(n+k-1,n-1);}//重複組み合わせ.
};

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

ll pow_mod(ll n, ll k, ll p) { // n^k(mod p)
	if (k == 0) {
		return 1;
	}
	ll res = pow_mod(n * n % p, k / 2, p);
	if (k & 1) {
		res = res * n % p;
	}
	return res;
}

bool vector_finder(std::vector<int> vec, int number) { // vector 内にnumberがあるかどうか
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance( vec.begin(), itr );
	if (index != vec.size()) { // 発見できたとき
		return true;
	}
	else { // 発見できなかったとき
		return false;
	}
}

int numSum(int x) {
	int sum = 0;
	while(x > 0) {
		sum += x%10;
		x /= 10;
	}
	return sum;
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int total = 0;
	for (int i = 1; i <= n; i++) {
		if (a <= numSum(i) && numSum(i) <= b) {
			total += i;
		}
	}
	return cout << total << endl, 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w == 0){
                break;
            }
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    if(i % 2 == 1){
                        if(j % 2 == 1){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }else{
                        if(j % 2 == 1){
                            System.out.print(".");
                        }else{
                            System.out.print("#");
                        }
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 36852
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long n,m,x;
  cin>>n>>m;
  long long a=0;
  for(long i=0;i<m;i++)
  {
    cin>>x;
    a+=x;
  }
  if(n-a>=0)
    cout<<n-a;
  else
    cout<<-1;
  return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void)
{
    int H, A;
    int ans;

    scanf("%d %d", &H, &A);

    if ((H % A) != 0) {
        ans = (H / A) + 1;
    } else {
        ans = H / A;
    }

    printf("%d", ans);

    return 0;
}

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

int main(void){
    int n = 0; 
    int a[100001];
    int abs_2 = 0;
    int ans = 0, now = 0;

    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        if(a[i] == 2){
            abs_2 = 1;
        }
    }
    // どのボタンを押しても、２が光ることはない
    if(abs_2 == 0){
        printf("-1\n");
        return 0;
    }

    // ボタンを２が光るまで押す
    now = 1;
    while(now != 2){
        ans++;
        now = a[now];
        if(ans > n){
            printf("-1\n");
            return 0;
        }
    }

    printf("%d\n", ans);

    return 0;

} 


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n; cin >> n;
	int h[n] = {};
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    int ans = 0;
    if (1 == n) {
        cout << ans << endl;
        return 0;
    }
    int tmp = 0;
    for (int i = 1; i < n; i++) {
        if (h[i - 1] >= h[i]) {
            tmp++;
            if (ans < tmp) ans = tmp;
        } else {
            tmp = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int n;
	cin>>n;
	int *A=new int[n+1];
	for ( int i=1; i<=n; i++) cin >> A[i];

	for( int i=1; i <= n; ++i) {
		cout << "node " << i << ": key = " << A[i] << ", ";
		if ( i>1 ) cout << "parent key = " << A[i/2] << ", ";
		if ( 2 * i <= n ) cout << "left key = " << A[ 2 * i ] << ", ";
		if ( 2 * i + 1 <= n) cout << "right key = " << A[ 2 * i + 1 ] << ", ";
		cout << endl; 
	}
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

ll calc(ll a, ll b) {
	return (b - a) / 2;
}

void solve(){
	ll n, a, b;
	cin >>n >> a >> b;
	if (a > b) {
		swap(a, b);
	}
	if ((b - a) % 2 == 0) {
		cout << calc(a, b) << endl;
	} else {
		ll v1 = a + calc(1, b - a);
		ll v2 = n - b + calc(a + (n - b - 1), n);
		cout << min(v1, v2) << endl;
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  if (a.front() == a.back()) {
    int x = a.front();
    if (x == n-1 || 2*x <= n) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (a.front() + 1 == a.back()) {
    int x = count(a.begin(), a.end(), a.front());
    int y = n - x;
    if (a.back() > x && 2*(a.back()-x) <= y) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 640