akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int,input().split()))
while True:
  att = min(a)
  attin = a.index(att)
  a = [i % att for i in a]
  a = [i for i in a if i != 0]
  a.append(att)
  if len(a) == 1:
    break
print(a[0])

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#define N 55
using namespace std;

int n, m, c;
bool v[N];
vector<int> a[N];

void f(int p, int q, int r) {
	int i;
	if (v[r]) return;
	v[r] = 1;
	for (i = 0; i < a[r].size(); i++) {
		if (p == r && q == i) continue;
		f(p, q, a[r][i]);
	}
}

int main()
{
	int i, j, t1, t2;
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		scanf("%d %d", &t1, &t2);
		a[t1].push_back(t2);
		a[t2].push_back(t1);
	}
	for (i = 1; i <= n; i++) {
		for (j = 0; j < a[i].size(); j++) {
			memset(v, 0, sizeof(v));
			f(i, j, i);
			if (!v[a[i][j]])
				c++;
		}
	}
    cout << c / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	ans := 0
	for i := 0; i < len(s)/2; i++ {
		if s[i] != s[len(s)-1-i] {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int inf = 5e18;  
const int mod = 1e9+7;
const int mod1 = 998244353;
const int nax = 1005;
string grid[nax];
int vis[nax][nax],dp[nax][nax],h,w,Cy,Cx,Dy,Dx;
inline bool valid(int y,int x)
 {
  return y>=0 && y<h && x>=0 && x<w && grid[y][x] == '.'; 
 } 
int dy[] = {0,1,0,-1,};
int dx[] = {-1,0,1,0};
priority_queue<pair<int,pii>> q;
void dijkstra()
 {
  q.push({0,{Cy,Cx}});
  while(!q.empty())
     {
      int y = q.top().ss.ff;
      int x = q.top().ss.ss;
      int v = -q.top().ff;
      q.pop();
      loop(i,0,4)
       if(valid(y+dy[i],x+dx[i]) && dp[y+dy[i]][x+dx[i]]>v)
         {
          dp[y+dy[i]][x+dx[i]] = v;
          q.push({-v,{y+dy[i],x+dx[i]}});
         }
      loop(i,-2,3)
       loop(j,-2,3)
        if(valid(y+i,x+j) && dp[y+i][x+j]>v+1)
           {
             dp[y+i][x+j] = v+1;
             q.push({-(v+1),{y+i,x+j}});
           }
       }
 }
void solve()
 {
  cin>>h>>w>>Cy>>Cx>>Dy>>Dx;
  Cy--,Cx--,Dy--,Dx--;
  loop(i,0,h)
   cin>>grid[i];
  loop(i,0,h)
   loop(j,0,w)
    dp[i][j] = inf;
  dijkstra();
  if(dp[Dy][Dx] == inf)
     cout<<-1;
  else 
     cout<<dp[Dy][Dx];
 } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
   /*int t;
   cin>>t;
   while(t--)*/
     solve();
 // cerr<<END<<1.0*clock()/CLOCKS_PER_SEC;
  return 0;
} 

Measured memory_bytes: 12700
#include <stdio.h>
char c[8][9], d[8][9];
int main() {
	for (int i = 0; i < 8; i++) scanf("%s", c[i]);
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 8; j++) {
			for (int k = 0; k < 8; k++) {
				d[j][k] = c[7 - k][j];
			}
		}
		printf("%d\n", i * 90 + 90);
		for (int j = 0; j < 8; j++) {
			for (int k = 0; k < 8; k++) {
				printf("%c", c[j][k] = d[j][k]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2656
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans;
int a[21],b[21],c[21];
void read()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	scanf("%d",&b[i]);
	for(int i=1;i<=n-1;i++)
	scanf("%d",&c[i]);
	return ;
}
int main()
{
	read();
	for(int i=1;i<=n;i++)
	{
		ans += b[a[i]];
		if(a[i] == a[i-1]+1)
		ans += c[a[i-1]];
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int M, T, P, R;
    while (cin >> M >> T >> P >> R, M) {
        vector<int> m(R), t(R), p(R), j(R);
        vector<vector<int>> wa(T, vector<int>(P, 0)), ac(T, vector<int>(P, -1));
        REP (i, R) {
            cin >> m[i] >> t[i] >> p[i] >> j[i];
            t[i]--; p[i]--;
            if (j[i] == 0) ac[t[i]][p[i]] = m[i];
            else wa[t[i]][p[i]]++;
        }
        vector<tuple<int, int, int>> v(T);
        REP (i, T) {
            int num = 0, sum = 0;
            REP (k, P) if (ac[i][k] != -1) {
                num++;
                sum += ac[i][k] + wa[i][k] * 20;
            }
            v[i] = make_tuple(-num, sum, -i);
        }
        sort(v.begin(), v.end());
        REP (i, v.size()) {
            int num, sum, idx;
            tie(num, sum, idx) = v[i];
            if (i) {
                int pnum, psum, pidx;
                tie(pnum, psum, pidx) = v[i - 1];
                if (num == pnum && psum == sum) cout << "=";
                else cout << ",";
            }
            cout << idx * -1 + 1;
        }
        cout << endl;
    }
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n, ans=0;
    cin >> n;
    for(ll i=1; i<=n; ++i){
      ll y=n/i;
      ans+=(y+1)*y*i/2;
    }
    cout << ans << "\n";
    return 0;
}   

Measured memory_bytes: 3568
package main

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

var sc *bufio.Scanner

func nextString() string {
	sc.Scan()
	i := sc.Text()
	return i
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

type Dice struct {
	nums []int
}

//  /1
// 4/2/3/5
//  /6
func (d *Dice) rotate(direction string) {
	if direction == "W" {
		d.nums[0], d.nums[2], d.nums[5], d.nums[3] = d.nums[2], d.nums[5], d.nums[3], d.nums[0]
	}
	if direction == "E" {
		d.nums[0], d.nums[2], d.nums[5], d.nums[3] = d.nums[3], d.nums[0], d.nums[2], d.nums[5]
	}
	if direction == "N" {
		d.nums[0], d.nums[4], d.nums[5], d.nums[1] = d.nums[1], d.nums[0], d.nums[4], d.nums[5]
	}
	if direction == "S" {
		d.nums[0], d.nums[1], d.nums[5], d.nums[4] = d.nums[4], d.nums[0], d.nums[1], d.nums[5]
	}

}

func (d *Dice) lr(direction string) {
	if direction == "L" {
		d.nums[3], d.nums[1], d.nums[2], d.nums[4] = d.nums[1], d.nums[2], d.nums[4], d.nums[3]
	}
	if direction == "R" {
		d.nums[3], d.nums[1], d.nums[2], d.nums[4] = d.nums[4], d.nums[3], d.nums[1], d.nums[2]
	}
}

func (d *Dice) getindex(value int) (index int) {
	for i, v := range d.nums {
		if v == value {
			index = i
			break
		}
	}
	return index
}

func check(a, b []int) bool {
	flag := true
	for i, v := range a {
		if v != b[i] {
			flag = false
			break
		}
	}
	return flag
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	dice1 := Dice{
		make([]int, 6),
	}
	dice2 := Dice{
		make([]int, 6),
	}
	iniDice2 := Dice{
		make([]int, 6),
	}
	for i := 0; i < 6; i++ {
		dice1.nums[i] = nextInt()
	}
	for i := 0; i < 6; i++ {
		dice2.nums[i] = nextInt()
		iniDice2.nums[i] = dice2.nums[i]
	}
	flag := true
	index := 0
	for i := 0; i < 6; i++ {
		for j := 0; j < 6; j++ {
			dice2.nums[j] = iniDice2.nums[j]
		}
		index = i
		if index == 1 {
			dice2.rotate("N")
		}
		if index == 2 {
			dice2.rotate("W")
		}
		if index == 3 {
			dice2.rotate("E")
		}
		if index == 4 {
			dice2.rotate("S")
		}
		if index == 5 {
			dice2.rotate("N")
			dice2.rotate("N")
		}
		for j := 0; j < 4; j++ {
			dice2.lr("L")
			flag = check(dice1.nums, dice2.nums)
			if flag {
				fmt.Println("Yes")
				break
			}
		}
		if flag {
			break
		}
	}
	if !(flag) {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1120
import numpy as np
h,w,k = map(int,input().split())
c = np.zeros((h,w), dtype="int")
f = lambda x: 1 if x=="#" else 0
for i in range(h):
    l=list(map(f,list(input())))
    c[i] = l

sum_=(c.sum())
cc=0
for i in range(2 ** h):
    l=[]
    for j in range(h):
        if ((i >> j) & 1): 
            l.append(j)
            
    for ii in range(2 ** w):
        ll=[]
        for jj in range(w):
            if ((ii >> jj) & 1): 
                ll.append(jj)
        if l and ll:
            ans = (c[l].sum()+c[:,ll].sum()-c[l][:,ll].sum())
        elif l and (not ll):
            ans = (c[l].sum())
        elif ll and (not l):
            ans = (c[:,ll].sum())
        else:
            ans = (0)
        #print(l,ll,ans)
        if sum_-k == ans:
            cc+=1
print(cc)

Measured memory_bytes: 27292
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <string>
    #include <cstring>
    #include <cstdlib>
    #define llong long long
    #define For(i,a,b) for(int i=(a);i<(b);i++)
    #define Rep(i,n) for(int i=0;i<(n);i++)
    using namespace std;
     
    void modifyprint(string c){
      Rep(i, c.size()){
        if (c[i]=='?'){
          c[i]='a';
        }
        cout << c[i];
      }
     
    }
     
    int main(){
      string a, b;
      cin >> a >> b;
      int cnt=0;
      for (int i=a.size()-1; i>=0; i--){
        if (b[b.size()-1]==a[i]||a[i]=='?'){
          bool result = true;
          for (int j=0; j<b.size(); j++){
            if(a[i-j]==b[b.size()-1-j]||a[i-j]=='?'){
              result &= true;
            } else {
              result &= false;
            }
          }
          if (result == true){
            for (int j=0; j<b.size(); j++){
              a[i-j] = b[b.size()-1-j];
            }
            modifyprint(a);
            cout << endl;
            cnt++;
            break;
          }
        }
      }
      if (cnt==0){
        cout << "UNRESTORABLE" << endl;
      }
      return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <math.h>

typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> w(n+1, 0);
    for(int i=1; i<n+1; ++i){
        cin >> w[i];
        w[i] += w[i-1];
    }
    int sm = w[n];
    int score = sm;
    for(auto ww : w){
        int st = abs(sm - 2 * ww);
        if (st > score){
            break;
        }
        score = st;
    }
    cout << score << endl;
    return 0;
}


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

char **copyArray(char**, int);
int stableCheck(char**, char**, int);

main(){
  int n,i,j,minj;
  char **b, **c, **A;
  char *tmp;

  scanf("%d", &n);

  //元の入力保持用 配列
  tmp = (char *)malloc(n*3*sizeof(char));
  A = (char **)malloc(n*sizeof(char *));
  for(i=0; i<n; i++){
    A[i]=tmp+3*i;
    scanf("%s", A[i]);
  }

  //バブルソート用にコピー
  b = copyArray(A,n);
  //bubbleSort
  for(i=0; i<n; i++){
    for(j=n-1; j>i; j--){
      if(b[j][1]<b[j-1][1]){
	//swap
	/*strcpy(tt, b[j]);
	strcpy(b[j],b[j-1]);
	strcpy(b[j-1], tt);*/
	tmp = b[j];
	b[j] = b[j-1];
	b[j-1] = tmp;
      }
    }
  }

  //セレクトソート用にコピー
  c = copyArray(A,n);
  //bubbleSort
  for(i=0; i<=n-1; i++){
    minj = i;
    for(j=i; j<=n-1; j++){
      if(c[j][1] < c[minj][1]) minj = j;
    }
    if(minj!=i){
	tmp = c[i];
	c[i] = c[minj];
	c[minj] = tmp;
    }
  }

  //print
  for(i=0; i<n-1; i++) printf("%s ", b[i]);
  printf("%s\nStable\n", b[i]); //バブルソートは常に安定
  //print
  for(i=0; i<n-1; i++) printf("%s ", c[i]);
  printf("%s\n", c[i]);
  if(stableCheck(b,c,n)==1)printf("Stable\n");
  else printf("Not stable\n");

  //メモリ開放
  /*free(A[0]);
  free(A);
  free(b[0]);
  free(b);
  free(c[0]);
  free(c);*/

  return 0;
}

char **copyArray(char **A, int n){
  //Aをこぴーした配列の先頭アドレスを返す
  int i;
  char **res, *tmp;
  tmp = (char *)malloc(n*3*sizeof(char));
  res = (char **)malloc(n*sizeof(char *));
  for(i=0; i<n; i++){
    res[i] = tmp+3*i;
    strcpy(res[i],A[i]);
  }

  return res;
}

int stableCheck(char** c, char** b, int n){
  int i;

  for(i=0; i<n; i++){
    if(c[i][1]==b[i][1]){
      if(c[i][0]!=b[i][0]) return 0;
    }
  }
  return 1;
}

Measured memory_bytes: 612
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
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC121().SolveA(new ConsoleInput(Console.In, ' '));
        }
    }

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

    class ABC121
    {
        public void SolveA(ConsoleInput cin)
        {
            var H = cin.ReadInt;
            var W = cin.ReadInt;
            var h = cin.ReadInt;
            var w = cin.ReadInt;
            WriteLine((W * H) - (W * h) - (H * w) + (h * w));
            ReadLine();
        }
    }
}

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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  string d = a + b + c;
  
  auto num = atoi(d.c_str());
  
  if(num%4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;
typedef long long int ll;
void sayYes() { cout << "Yes" << endl; };
void sayNo() { cout << "No" << endl; };
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define rep(i, n) for (ll i = 0; i < n; i++)

void Main()
{
    // int n;
    // cin >> n;
    // vector<vector> a(n);
    // rep(i, n)
    // {
    //     cin >> a[i];
    // }

    int a, b;
    cin >> a >> b;
    if (a - 2 * b < 0)
        cout << 0 << endl;
    else
        cout << (a - 2 * b) << endl;

    // cout << ans << endl;
    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

def sumofdigit(x):
  ans = 0
  while(x>0):
    ans+=x%10
    x=int(x/10)
  return ans

sum = 0
for i in range(1,N+1):
  tmp = sumofdigit(i)
  if tmp >= A and tmp <= B:
    sum+=i
print(sum)

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

using Edge = pair<int,int>; // (隣接頂点, 辺番号)
using Graph = vector<vector<Edge>>;
int N;
Graph G;

// v: 頂点、p: 親、pc: 親から来た辺の色、res: 色
void dfs(int v, int p, int pc, vector<int> &res) {
    int color = 1;
    if (color == pc) ++color;
    for (auto e : G[v]) {
        if (e.first == p) continue; // 逆流しない
        res[e.second] = color;
        dfs(e.first, v, color, res);
        ++color;
        if (color == pc) ++color;
    }
}

int main() {
    cin >> N;
    G.assign(N, vector<Edge>());
    for (int i = 0; i < N-1; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].emplace_back(b, i); 
        G[b].emplace_back(a, i);
    }
    int max_color = 0;
    for (int i = 0; i < N; ++i) chmax(max_color, (int)G[i].size());
    vector<int> res(N-1, -1);
    dfs(0, -1, -1, res);
    cout << max_color << endl;
    for (auto v : res) cout << v << endl;
}

Measured memory_bytes: 11012
#include <iostream>
#include <string>
#include <set>

using namespace std;

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

  set<char> pasts;

  for (int i = 0; i < s.size(); ++i) {
    if (pasts.find(s[i]) == pasts.end())
      pasts.insert(s[i]);
  }

  if (pasts.size() == 26) {
    cout << "None" << endl;
    return 0;
  }

  char c;
  for (c = 'a'; c <= 'z'; ++c) {
    if (pasts.find(c) == pasts.end())
      break;
  }

  cout << c << endl;

  return 0;
}

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

const int N = 200010;

char s[N];

int main(){
	scanf("%s", s);
	int len = strlen(s), begin = 0, end = len - 1;
	for (; s[begin] != 'A'; ++ begin);
	for (; s[end] != 'Z'; -- end);
	return printf("%d\n", end - begin + 1), 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int ans = 0;
        for (int i = 0; i < n - 2; i++)
        {
            if (new int[3] { p[i], p[i + 1], p[i + 2] }.OrderBy(f => f).ToArray()[1] == p[i + 1]) ans++;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
#include <stdio.h>

int main(void){
    int i,x;
    
    for(i=0;i<10000;i++){
        scanf("%d",&x);
        if(x==0){
            break;
        }else{
        printf("Case %d: %d\n",i+1,x);
        }
    }
    return 0;
}


Measured memory_bytes: 2032
#include <stdio.h>

int n, s;
int cnt = 0;

//i: 現在まで選んだ値の数
//sum: 選んだ数の和
//next: 次に選ぶ数
void dfs(int i, int sum, int next) {
    if(i >= n) {
         if(sum == s) {
         	++cnt;
         }
         return;
    }
    if(next >= 10) {
        return;
    }
    
    dfs(i,   sum,      next+1); //nextを選ばないパターン
    dfs(i+1, sum+next, next+1); //nextを選ぶパターン
    return;
}

int main() {
    while(scanf("%d %d", &n, &s) != EOF) {
        if(n == 0 && s == 0) break;
        cnt = 0;
        dfs(0, 0, 0);
        printf("%d\n", cnt);
    }
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

ll a[200005];

ll getlastdigit(ll x){
  return x%10;
}

ll getfirstdigit(ll x){
  while(x/10 !=0){
    x/=10;
  }
  return x;
}

ll getrev(ll x){
  ll rev = 0;
  while(x){
    rev = rev*10 + x%10;
    x/=10;
  }
  return rev;
}

ll m[200];

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n;
  cin>>n;
  for(ll i=1;i<=n;i++){
    ll x = getfirstdigit(i);
    ll y = getlastdigit(i);
    if(y==0)
      continue;
    ll a = 10*x+y;
    //debug1(a);
    m[a]++;
  }
  ll ans = 0;
  for(ll i=11;i<=99;i++){
    if(getlastdigit(i)==0)
      continue;
    ll j = getrev(i);
    if(j>i){
      ans = ans + m[i]*m[j]*2;
      //cout<<i<<" "<<m[i]*m[j]<<endl;
    }else if(j==i){
      ans = ans + m[i]*m[j];
    }
    //debug2(m[i],m[j]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#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 REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(1e18+1)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll ans = 0;
  ll n;cin>>n;
  vector<ll> D;
  rep(i,n){
    ll d;cin>>d;
    D.push_back(d);
  }
  rep(i,n){
    rep(j,n){
      if(i==j) continue;
      ans += D[i] * D[j];
    }
  }
  cout<<ans/2<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld DINF = 1e12;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  ll h, w, k;
  string s[10];
  cin >> h >> w >> k;
  rep(i, h) cin >> s[i];

  ll Min = INF;
  rep(bi, 1 << (h - 1))
  {
    bitset<9> bs(bi);
    ll cnt = 0;
    rep(i, h) cnt += bs[i];
    vector<int> v;
    v.push_back(0);
    rep(i, h - 1)
    {
      if (bs[i])
        v.push_back(i + 1);
    }
    v.push_back(h);


    ll a[10][1000] = {};
    rep(vi, v.size() - 1)
    {
      REP(i, v[vi], v[vi + 1])
      {
        rep(j, w)
        {
          if (s[i][j] == '1')
            a[vi][j]++;
        }
      }
    }

    bool can = true;
    rep(vi, v.size() - 1)
    {
      rep(j, w)
      {
        if (a[vi][j] > k)
        {
          can = false;
          break;
        }
      }
      if (!can)
        break;
    }
    if (!can)
      continue;
    ll choco[10] = {};
    rep(j, w)
    {
      bool uncnt = true;
      rep(vi, v.size() - 1)
      {
        if (choco[vi] + a[vi][j] > k)
        {
          uncnt = false;
          break;
        }
      }
      if (uncnt)
      {
        rep(vi, v.size() - 1)
        {
          choco[vi] += a[vi][j];
        }
      }
      else
      {
        cnt++;
        rep(vi, v.size() - 1)
        {
          choco[vi] = a[vi][j];
        }
      }
    }
    Min = min(Min, cnt);
  }
  cout << Min << endl;
  return 0;
}

Measured memory_bytes: 384
(println (let [[x1 y1 x2 y2] (map #(Integer/parseInt %) (clojure.string/split (read-line) #"\s"))
               dx (- x1 x2)
               dy (- y1 y2)]
           (str (+ x2 dy) " " (- y2 dx) " " (+ x1 dy) " " (- y1 dx))))

Measured memory_bytes: 60420
import java.util.Scanner

object Main extends App  {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val al = Vector.fill(n)(sc.nextLong)

  val abs = al.map(Math.abs)
  val sum = abs.sum

  val res =
    if(al.count(_ < 0) % 2 == 0) sum
    else {
      val minus = abs.min
      sum - 2 * minus
    }

  println(res)
}


Measured memory_bytes: 53956
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

struct Point {
  int x;
  int y;
  Point(int _x,int _y) : x(_x),y(_y) {}
  bool operator<(const Point& p) const{
    return x < p.x;
  }
};

int main(){
  int total_treasure,total_region;
  
  while(~scanf("%d %d",&total_treasure,&total_region)){
    vector<Point> treasures;
    vector<int> treasures_x;

    for(int i=0;i<total_treasure;i++){
      int x,y;
      scanf("%d %d",&x,&y);
      treasures.push_back(Point(x,y));
      treasures_x.push_back(x);
    }
    sort(treasures.begin(),treasures.end());
    sort(treasures_x.begin(),treasures_x.end());

    for(int i=0;i<total_region;i++){
      int x[2],y[2];
      scanf("%d %d %d %d",x,y,x+1,y+1);
      int left_idx = lower_bound(treasures_x.begin(),treasures_x.end(),x[0]) - treasures_x.begin();
      int right_idx = upper_bound(treasures_x.begin(),treasures_x.end(),x[1]) - treasures_x.begin() - 1;

      int count = 0;
      for(int j=left_idx;j<=right_idx;j++){
      	if(treasures[j].y < y[0] || y[1] < treasures[j].y) continue;
      	count++;
      }
      printf("%d\n",count);
    }
  }
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,w,p;
    int ans=0;
    cin>>n>>w;
    int m[n][w]={};
    int b[n][w]={};
    fr(i,n){
        fr(l,w){
            char c;
            cin>>c;
            if(c=='.')m[i][l]=1;
        }
    }
    p=0;
    fr(i,w){
        fr(l,n){
            if(m[l][i])++p;
            if(m[l][i]-1){
                fr(k,p+1){
                    b[l-k][i]+=p;
                }
                p=0;
            }
            if(l==n-1){
                fr(k,p){
                    b[l-k][i]+=p;
                }
                p=0;
            }
        }
    }
    fr(l,n){
        fr(i,w){
            if(m[l][i])++p;
            if(m[l][i]-1){
                fr(k,p+1){
                    b[l][i-k]+=p;
                }
                p=0;
            }
            if(i==w-1){
                fr(k,p){
                    b[l][i-k]+=p;
                }
                p=0;
            }
        }
    }
    fr(l,n){
        fr(i,w){
            if(m[l][i]==1) ans=max(b[l][i],ans);
        }
    }
    cout<<ans-1;
}

Measured memory_bytes: 34916
use std::io::*;
use std::str::FromStr;

fn markid(c: char) -> usize {
    for (mark, id) in "SHCD".chars().zip(0..4) {
        if c == mark {
            return id;
        }
    }
    panic!();
}

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());

    let n: usize = sc.next();
    let mut appear = vec![vec![false; 13]; 4];

    for _ in 0..n {
        let mark = sc.char();
        let num = sc.next::<usize>() - 1;

        let id = markid(mark);
        appear[id][num] = true;
    }

    for (mark, id) in "SHCD".chars().zip(0..4) {
        for num in 0..13 {
            if !appear[id][num] {
                println!("{} {}", mark, num + 1);
            }
        }
    }
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }

    fn char(&mut self) -> char {
        self.chars()[0]
    }
}



Measured memory_bytes: 5032
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = a % 10;
		if(b == 2 || b == 4 || b == 5 || b == 7 || b == 9) {
			System.out.println("hon");
		}if(b == 0 || b == 1 || b == 6 || b == 8) {
			System.out.println("pon");
		}if(b == 3){
			System.out.println("bon");
		}
	}

}


Measured memory_bytes: 35584
/* #                          */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/

int n, p;
string s;
vi cnt;

void sol() {
    ll ans = 0;
    int pow10 = 1;
    int sum = 0;

    for (int i = 0; i < n; i++) {
        char x = s[i] - '0';
        //1의 자리에서 부터 검사하며 p의 배수인지 검사하고 나머지가 같은 녀석들을 count한다.
        sum = (sum + x * pow10) % p;

        //같은 나머지가 나오게 했다는 말은 그 나머지가 나온 부분에 대해 현재 추가된 것이 3의 배수라는 말.
        ans += cnt[sum]++;
        pow10 = pow10 * 10 % p;
    }
    cout << ans <<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);

    cin >> n >> p; 
    cnt.assign(p, 0); cnt[0] = 1;
    cin >> s;

    // 2 또는 5의 배수일땐 다르게 처리, 10이 divisible하므로 
    //현재 자리가 dibisible하면 모든 postfix에 대하여 True
    if (p == 2 || p == 5) {
        ll ans(0);
        int z = 0;
        for (int i = 0; i < n; i++) {
            char x = s[i] - '0';
            if (x % p == 0) ans += ((ll)i + 1);
        }
        cout << ans << endl;
        return 0;
    }
    else {
        reverse(s.begin(), s.end()); //1의 자리서부터 접근.
        sol();
    }

    return 0;
}

Measured memory_bytes: 848
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a%b) : a;}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin >> n >> m;
  vector<int> l(m);
  vector<int> r(m);
  vector<int> L(m);
  vector<int> R(m);  
  for (int i=0;i<m;++i) {
    cin >> l[i];
    cin >> r[i];
  }
  L=l;
  R=r;
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());
  int k;
  if (R[0]>=L[m-1]) {
    k=R[0]-L[m-1]+1;
    cout << k << endl;
  } else {
    cout << 0<< endl;
  }
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;


int main() {

	string s;
	bool N = false, S = false, W = false, E = false;


	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'N') {
			N = true;
		}
		if (s[i] == 'S') {
			S = true;
		}
		if (s[i] == 'E') {
			E = true;
		}
		if (s[i] == 'W') {
			W = true;
		}
	}

	if ((N == S) && (E == W)) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}



	return 0;
}


Measured memory_bytes: 256
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv) {
  char s[11], t[11], u[11];
  int a, b;
  scanf("%s %s %d %d %s", s, t, &a, &b, u);
  if (strcmp(s, u) == 0) {
    printf("%d %d\n", a - 1, b);
  } else {
    printf("%d %d\n", a, b - 1);
  }
  return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int x[3];
    for(int i = 0; i < 3; i++) cin >> x[i];
    sort(x,x+3);
    int ans = 0;
    ans += x[2]-x[1],x[0] += x[2]-x[1];
    ans += (x[2]-x[0])/2;
    if(x[0]%2 != x[2]%2) ans += 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 0], [0, 2, 1, 1], [2, 1, 0, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0]]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if x[j] == y[z[i][j]] and x[-j-1] == y[-z[i][j]-1]:
            pass
        elif x[j] == y[-z[i][j]-1] and x[-j-1] == y[z[i][j]]:
            order[j] = 1
            if x[j] == x[-j-1]:
                order[j] = 2
        else:
            break
    else:
        if 2 in order or z[i][3] == sum(order) % 2:
            print('Yes')
            break
else:
    print('No')

Measured memory_bytes: 7736
#include <iostream>

using namespace std;

int dp[5001][2],dp2[5001][2];
int inf=1000000000;

int main(){
    int n,sec[10000];
    cin>>n;
    for(int i=0;i<n-1;++i) cin>>sec[i];
    for(int i=0;i<=n/2;++i){
        for(int j=0;j<2;++j){
            dp[i][j]=inf;dp2[i][j]=inf;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<n;++i){
        int t=min(n/2,i);
        for(int j=0;j<=t;++j){
            if(i%2==0){
                dp2[j+1][0]=min(dp[j][0],dp[j][1]+sec[i]);
                dp2[j][1]=min(dp[j][1],dp[j][0]+sec[i]);
            }
            else{
                dp[j+1][0]=min(dp2[j][0],dp2[j][1]+sec[i]);
                dp[j][1]=min(dp2[j][1],dp2[j][0]+sec[i]);
            }
        }
        if(i%2==0) dp[0][0]=inf;
        else dp2[0][0]=inf;
    }
    cout<<dp[n/2][0]<<endl;
    return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  constexpr size_t mx = 100;
  std::array<std::array<bool, mx>, mx> grd = {};
  for (size_t i = 1; i < mx - 1; i++) {
    for (size_t j = 1; j < mx; j += 2) {
      grd.at(i).at(j) = true;
    } 
  }
  for (size_t j = 0; j < mx; j++) {
    grd.at(mx - 1).at(j) = true;
  }
  auto punch = [&] (int k) {
    assert(k >= 0);
    if (k == 0) return;
    for (size_t j = 0; j < mx; j += 2) {
      for (size_t i = 1; i < mx - 1; i += 2) {
        grd.at(i).at(j) ^= 1;
        k--;
        if (k == 0) break;
      }
      if (k == 0) break;
    }
  };
  auto transpose = [&] {
    std::array<std::array<bool, mx>, mx> new_grd = {};
    for (size_t i = 0; i < mx; i++) {
      for (size_t j = 0; j < mx; j++) {
        new_grd.at(i).at(j) = grd.at(mx - 1 - i).at(mx - 1 - j);
      }
    }
    grd = new_grd;
  };
  int a, b; std::cin >> a >> b;
  punch(a - 1); transpose();
  punch(b - 1); transpose();
  std::cout << mx << " " << mx << std::endl;
  for (size_t i = 0; i < mx; i++) {
    for (size_t j = 0; j < mx; j++) {
      std::cout << (grd.at(i).at(j) ? "#" : ".");
    }
    std::cout << std::endl;
  }
  return 0;
}

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

using namespace std;

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

int main(){
    long long n, s;
    scanf("%lld %lld", &n, &s);
    if (n == s){
        printf("%lld\n", n + 1);
        return 0;
    }
    for (long long i = 2; i * i <= n; i++){
        if (f(i, n) == s){
            printf("%lld\n", i);
            return 0;
        }
    }
    long long ans = -1;
    for (long long i = 1; i * i < n; i++){
        long long b = (n - s) / i + 1;
        if (b >= 2 && f(b, n) == s)
            ans = b;
    }
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

int main(){
    int a, b;
    int arr[3];
    cin >> a >> b;
    arr[0] = a+b;
    arr[1] = a-b;
    arr[2] = a*b;
    sort(arr,arr+3);
    cout << arr[2] << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
	string m,n,o;
	int i,flag=0;
	cin >> m >> n;
	m=m+m;
	for(i=0;i<(int)m.size();i++){
		o=m.substr(i,n.size());
		if(n==o){
			flag=1;
			break;
		}
	}
	if(flag==1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3188
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
const int MX = 200000+7;
int a[MX];
int n;

template<class T>
vector<T> calc_divisor(T n) {
    vector<T> res;
    for (T i = 1; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            T j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    // sort(res.begin(), res.end()); //大きい順
    return res;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> n;
    unordered_map<int, int> mp;
    FOR(i,0,n-1) {
        cin >> a[i];
        mp[a[i]]++;
    }
     
    int ans = 0;
    for(int i = 0; i <= n-1; i++) {
        if(mp[a[i]] > 1) continue;
        bool ok = true;
        for(auto e: calc_divisor(a[i])) {
            if(e == a[i]) continue;
            if(mp[e] > 0) ok = false;
        }
        if(ok) ans++;
    }

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


Measured memory_bytes: 32540
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,k,i,j,l,o,ans = 0,now;scanf("%d %d %d\n",&h,&w,&k);
  char m[h][w];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++) scanf("%c",&m[i][j]);
    scanf("\n");
  }
  for(i=0;i<(1<<h);i++){
    bitset<6> hb(i);
    for(j=0;j<(1<<w);j++){
      bitset<6> wb(j);
      now = 0;
      for(l=0;l<h;l++){
        for(o=0;o<w;o++) now += m[l][o]=='#' && hb[l] && wb[o];
      }
      ans += k==now;
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 3824
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		StringBuilder s = new StringBuilder().append(sc.nextLine());

		int ans = 0;
		int i = 0;
		while(i<s.length()-1) {
			if(s.substring(i, i+2).equals("01") ||
			   s.substring(i, i+2).equals("10")) {
				s = s.delete(i, i+2);
				ans += 2;
				if(i > 0) i--;
			}else {
				i++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 34496
d = {'1': ['.', ',', '!', '?', ' '], '2': ['a', 'b', 'c'], '3': ['d', 'e', 'f'], '4': ['g', 'h', 'i'], '5': ['j', 'k', 'l'], '6': ['m', 'n', 'o'], '7': ['p', 'q', 'r', 's'], '8': ['t', 'u', 'v'], '9': ['w', 'x', 'y', 'z']}

n = int(input())
m = [input() for i in range(n)]
for mm in m:
    l = [x for x in mm.split('0') if not x == '']
    for x in l:
        print(d[x[0]][len(x)%len(d[x[0]]) - 1], end='')
    print()



Measured memory_bytes: 6516
#include "stdio.h"

int main(){
	
	int a,b,c,a1,b1,c1;
	
	scanf("%d %d %d",&a,&b,&c);
	
	int count=0;
	
	while(1){
		if((a%2==1)||(b%2==1)||(c%2==1)){
			break;
		}
		
		if((a==b)&&(a==c)){
			count=-1;
			break;
		}
		
		a1=a,b1=b,c1=c;//can i group together for one row?//ok
		
		a=(b1+c1)/2;
		b=(c1+a1)/2;
		c=(a1+b1)/2;//can i group together with the above//ok
		
		count++;
	}
	
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 128
x = int(input())
n = 100000

def binp(arr, val):
    left,right = 0,len(arr)-1
    while left <= right:
        mid = (left+right)//2
        if val==arr[mid]: return mid
        elif val>=arr[mid]: left = mid+1
        else: right = mid-1
    return 0

def binn(arr, val):
    left,right = 0,len(arr)-1
    while left >= right:
        mid = (left+right)//2
        if val==arr[mid]: return mid
        elif val>=arr[mid]: right = mid+1
        else: left = mid-1
    return 0

ap = [i**5 for i in range(n)]
an = [-(i**5) for i in range(n)]

for b in range(-n,n):
    val = x + b**5
    a = max(binp(ap, val), binn(an,val))
    if a: print(a,b) ; break


Measured memory_bytes: 20064
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=200005;

void solve()
{
    int n,d;
    cin>>n>>d;
    int x,y,ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        int z=x*x+y*y;
        if(z<=(d*d))
            ans++;
    }
    cout<<ans<<endl;
    
    
}

int32_t main()
{
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}


Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    ll n,k; cin >> n >> k;
    ll x=n;

    if(n>=k) x = n % k;

    x = min(x, abs(x-k));

    cout << x << endl;
}

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

int main()
{
    int n, m, d;

    cin >> n >> m;

    int cnt = 0;
    for( int i = 0; i < m; i++ )
    {
        cin >> d;
        if( d <= m )
            cnt++;
    }

    cout << m - cnt << endl;

    return 0;
}



Measured memory_bytes: 3104
#include <stdio.h>

int main(void)
{
    int n;
    float exam = 0.0;
    scanf("%d", &n);
    float a[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%f", &a[i]);
        exam += 1 / a[i];
    }
    printf("%f\n", 1 / exam);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize(2)
#include <cstdio>
#include <cstring>
using namespace std;

char a[110000];

int main()
{
	scanf("%s",a);
	int l=strlen(a);
	for(int i=0;i<l;i+=2) printf("%c",a[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
//
	vector<char>s(9);
	rep0(i, 8) {
		cin >> s[i];
	}
	cout << s[0] << s[4] << s[8] << endl;
	return 0;
}

Measured memory_bytes: 256