akhauriyash/Code-Regression huggingface dataset:
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define mem(i,j) memset(i,j,sizeof i);
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define bit(s,i) (((s)>>(i))&1LL)
#define lowbit(x) (x&-x)
#define siz(v) (long long)v.size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

bool solve() {
    int n, mx=0;
    cin >> n;
    vector<int> arr(n+1), ans(n+1), aa;
    for(int i = 1; i <= n; i++) cin >> arr[i];
    for(int i = n; i >0; i--) {
        int sum=0;
        for(int j = i; j <= n; j+=i) sum+=ans[j];
        if((sum&1)!=arr[i]) {
            ans[i]=1;
            aa.pb(i);
        }
    }
    sort(all(aa));
    cout << aa.size() <<endl;
    for(int i: aa) cout << i << ' ';
    return true;
}

int main() {
    EmiliaMyWife

    solve();

	return 0;
}


Measured memory_bytes: 3192
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
        long sum = 0;
        for(long i = 0; i < n; i++){
            sum += i;
        }

        System.out.println(sum);

    }

}


Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>
	
int main() {
	ll n, k;
	cin >> n >> k;
	vector<double> r(n + 1);
	REP(i, n) {
		double a;
		cin >> a;
		a = (a + 1) / 2;
		r[i + 1] = r[i] + a;
	}
	double ans = 0;
	REP(i, n - k + 1)ans = max(ans, r[i + k] - r[i]);
	cout << fixed << ans << endl;
}



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

int main(){
	// sengen
	int a[3];
	// nyuryoku
	cin >> a[0] >> a[1] >> a[2];
	// keisan
	sort(a,a+3);
	cout << a[0] + a[1] + a[2]*10 << endl;
	// syutsuryoku
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;cin>>s;int cnt1=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='x') cnt1++;
	}
	if(cnt1>=8) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}

Measured memory_bytes: 256
import sys
import bisect
inf = 10**15
mod = 10**9+7
ans = []
n,a,b,c = map(int, input().split())
abc = []


for i in range(n):
    s = input()
    abc.append(s)

for i in range(n):
    s = abc[i]
    if s == 'AB':
        if a > b:
            a-=1
            b+=1
            ans.append('B')
        elif a < b:
            a+=1
            b-=1
            ans.append('A')
        else:
            if i != n-1 and abc[i+1] == 'AC':
                a += 1
                b -= 1
                ans.append('A')
            else:
                a -= 1
                b += 1
                ans.append('B')
    elif s == 'BC':
        if b > c:
            b-=1
            c+=1
            ans.append('C')
        elif b < c:
            b+=1
            c-=1
            ans.append('B')
        else:
            if i != n-1 and abc[i + 1] == 'AB':
                b += 1
                c -= 1
                ans.append('B')
            else:
                b -= 1
                c += 1
                ans.append('C')
    else:
        if c > a:
            c-=1
            a+=1
            ans.append('A')
        elif c < a:
            c+=1
            a-=1
            ans.append('C')
        else:
            if i != n-1 and abc[i + 1] == 'BC':
                c += 1
                a -= 1
                ans.append('C')
            else:
                c -= 1
                a += 1
                ans.append('A')
    if a < 0 or b < 0 or c < 0:
        print('No')
        sys.exit()
if a >= 0 and b >= 0 and c >= 0:
    print('Yes')
    for num in ans:
        print(num)
else:
    print('No')

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

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var dir = new Dictionary<string, int[]>()
            {
                { "N", new[]{ 0,1 } },
                { "E", new[]{ 1,0} },
                { "W",new[]{ -1,0} },
                { "S",new[]{0,-1} }
            };

            var n = 0;
            while ((n = readNum()) != 0)
            {
                var count = 0;
                var area = new bool[21, 21];
                int x = 10, y = 10;
                for (var i = 0; i < n; i++)
                {
                    var xy = readNums();
                    area[xy[0], xy[1]] = true;
                }

                var m = readNum();
                for (var i = 0; i < m; i++)
                {
                    var dl = Console.ReadLine().Split(' ');
                    var d = dl[0];
                    var l = int.Parse(dl[1]);
                    for (int j = 0; j < l; j++)
                    {
                        x = x + dir[d][0];
                        y = y + dir[d][1];
                        if (area[x, y])
                        {
                            area[x, y] = false;
                            count++; ;
                        }
                    }
                }
                Console.WriteLine((count == n) ? "Yes" : "No");
            }
        }

        static int readNum()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] readNums()
        {
            return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        }
    }
}

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

string a[20];
int h, w;

int bfs(int x, int y, int xx, int yy){
  if (a[x][y] == '#' || a[xx][yy] == '#') return 0;
  bool vis[20][20];
  int cnt[20][20];
  for (int i = 0; i < 20; i++){
    for (int j = 0; j < 20; j++){
      vis[i][j] = false;
      cnt[i][j] = 0;
    }
  }
  int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

  queue < pair <int, int> > q;
  q.push({x, y});
  vis[x][y] = true;
  while (q.size()){
    auto r = q.front();
    q.pop();
    for (int i = 0; i < 4; i++){
      if (r.first + dx[i] < 0 || r.first + dx[i] >= h || r.second + dy[i] < 0 || r.second + dy[i] >= w || a[r.first + dx[i]][r.second + dy[i]] == '#' || vis[r.first + dx[i]][r.second + dy[i]])
        continue;
      vis[r.first + dx[i]][r.second + dy[i]] = true;
      q.push({r.first + dx[i], r.second + dy[i]});
      cnt[r.first + dx[i]][r.second + dy[i]] = cnt[r.first][r.second] + 1;
    }
  }
  return cnt[xx][yy];
}

void solve(){
  cin >> h >> w;
  for (int i = 0; i < h; i++) cin >> a[i];

  int ans = 0;
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      for (int ii = 0; ii < h; ii++){
        for (int jj = 0; jj < w; jj++){
          ans = max(ans, bfs(i, j, ii, jj));
          //cout << ans << ' ' << i << ' ' << j << ' ' << ii << ' ' << jj << endl;
        }
      }
    }
  }
  cout << ans << endl;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  solve();

  return 0;
}


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

int main() {
	ios :: sync_with_stdio(false);
	cin.tie(0);
	string s, t, u;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	cin >> u;
	if(u == s) {
		cout << a - 1 << " " << b;
	}
	else {
		cout << a << " " << b - 1;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
X = list(map(int,input().split()))
K = int(input())
K += 1

for i in range(K):
    for j in range(K-i):
        for k in range(K-i-j):
            if X[0]*(2**i) < X[1]*(2**j) and X[1]*(2**j) < X[2]*(2**k):
                print('Yes')
                sys.exit()
print('No')



Measured memory_bytes: 9160
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define eps 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES\n"; }
void NO() { cout << "NO\n"; }
void Yes() { cout << "Yes\n"; }
void No() { cout << "No\n"; }
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int dx[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[] = { 0, -1, 0, 1, -1, -1, 1, 1 };

int main() {
	int x, y;
	cin >> x >> y;
	cout << gcd(x, y) << endl;

	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
char S[12];
int N;
int main(){
  int i, res=1073709056;
  N = rd(S);
  for(i=0;i<N;i++){
    S[i] -= '0';
  }
  for(i=2;i<N;i++){
    chmin(res, abs(100*S[i-2] + 10*S[i-1] + S[i] - 753));
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// char S[12]; int N;
// {
//   int i, res = int_inf;
//   rd(S@N);
//   rep(i,N) S[i] -= '0';
//   rep(i,2,N) res <?= abs(100S[i-2] + 10S[i-1] + S[i] - 753);
//   wt(res);
// }


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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = inputs[0];
        var m = inputs[1];
        var briges = new Tuple<int, int>[m];
        for(int i = 0; i < m; i++)
        {
            var tmp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            briges[i] = new Tuple<int, int>(tmp[0], tmp[1]);
        }


        var trees = new UnionFind<int>();
        for (int i = 1; i <= n; i++) trees.Add(i);

        var answers = new long[m];

        answers[0] = (long)(n - 1) * n / 2;
        for(long i = 1; i < m; i++)
        {
            var a = briges[m - i].Item1;
            var b = briges[m - i].Item2;

            if (trees.IsSame(a, b))
            {
                answers[i] = answers[i - 1];
                continue;
            }

            // 不便さを調べる
            answers[i] = answers[i - 1] - (trees.Size(a) * trees.Size(b));

            // 結合をする
            trees.Unite(a, b);
        }

        foreach (var item in answers.Reverse()) Console.WriteLine(item);
    }
}

public class UnionFind<T>
{
    private Dictionary<T, Node> _nodes;

    public UnionFind()
    {
        _nodes = new Dictionary<T, Node>();
    }

    /// <summary>
    /// 要素を追加する
    /// </summary>
    public void Add(T item)
    {
        _nodes[item] = new Node(item);
    }

    /// <summary>
    /// 集合を結合する
    /// </summary>
    public void Unite(T x, T y)
    {
        Node.Unite(_nodes[x], _nodes[y]);
    }

    /// <summary>
    /// 同じ集合に属するか
    /// </summary>
    public bool IsSame(T x, T y)
    {
        return _nodes[x].Find() == _nodes[y].Find();
    }

    /// <summary>
    /// グループに属する頂点の数を返す
    /// </summary>
    public long Size(T x)
    {
        return _nodes[x].Size;
    }

    class Node
    {
        private int _rank;
        private long _size;
        private Node _parent;

        // 常に根がグループに属する頂点数を保持するように
        public long Size => Find()._size;

        public Node(T item)
        {
            _rank = 0;
            _size = 1;
            _parent = this;
        }

        public Node Find()
        {
            if (_parent == this) return this;

            // 根を見つけるとともに、親が根になるようにつなぎ変える
            Node parent = _parent.Find();
            _parent = parent;
            return parent;
        }

        public static bool Unite(Node x, Node y)
        {
            var rootX = x.Find();
            var rootY = y.Find();

            if (rootX == rootY) return false;

            // ランク(木の高さ)が低い方を高い方につなげる
            if (rootX._rank < rootY._rank)
            {
                rootX._parent = rootY;
                rootY._rank = Math.Max(rootX._rank + 1, rootY._rank);
                rootY._size = rootX._size + rootY._size;
            }
            else
            {
                rootY._parent = rootX;
                rootX._rank = Math.Max(rootY._rank + 1, rootX._rank);
                rootX._size = rootX._size + rootY._size;
            }

            return true;
        }
    }
}

Measured memory_bytes: 38780
import sys

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()

def main():
    cnt = [0] * 3
    for c in s:
      if c == 'R': cnt[0] += 1
      elif c == 'G': cnt[1] += 1
      else: cnt[2] += 1
    res = cnt[0] * cnt[1] * cnt[2]
    for i in range(n - 2):
      for j in range(i + 1, n - 1):
        k = 2 * j - i
        if k >= n: break
        res -= s[i] != s[j] and s[j] != s[k] and s[k] != s[i]
    print(res)

if __name__ == '__main__':
  main()

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

bool is_reachable(int dt, int dx, int dy) {
    if (dt < dx + dy) {
        return false;
    }
    if ((dt - dx - dy) % 2 != 0) {
        return false;
    }
    return true;
}

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

    vector<vector<int>> info(N + 1, vector<int>(3));
    for (int j = 0; j < 3; ++j) {
        info.at(0).at(j) = 0;
    }
    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> info.at(i).at(j);
        }
    }

    for (int i = 0; i < N; ++i) {
        int dt = info.at(i + 1).at(0) - info.at(i).at(0);
        int dx = abs(info.at(i + 1).at(1) - info.at(i).at(1));
        int dy = abs(info.at(i + 1).at(2) - info.at(i).at(2));

        if (!(is_reachable(dt, dx, dy))) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <map>
#include <cmath>
#include <bitset>
#include <deque>
#include <queue>
#define INF (1LL<<31)
#define fst first
#define snd second
typedef long long ll;
typedef std::pair<int,int> ii;
using namespace std;

int main(){
  int d[3]={};
  int n;
  bool flg=false;
  cin>>n;
  for(int i=0;i<n;i++){
    int a,count;
    cin>>a;
    count=0;
    for(int j=0;j<2;j++){
      if(a%2)break;
      a/=2;count++;
    }
    d[count]++;
  }
  if(d[1]){
    if(d[0]<=d[2])flg=true;
  }else{
    if(d[0]-1<=d[2])flg=true;
  }
  cout<<(flg?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n;
  int frag=0;
  char s[101];
  scanf("%d",&n);
  scanf("%s",s);
  if(n%2!=0){
    frag=1;
  //  goto 24;
  }else{
    for(int i=0;i<n/2;i++){
      if(s[i]!=s[i+n/2]){

        frag=1;

        break;

      }
    }
  }
  if(frag==0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	map<string, int> mp;
	for(int i = 0; i < n; i++){
		string s; cin>>s;
		mp[s]++;
	}
	int val = 0;
	for(auto x : mp){
		val = max(val, x.second);
	}
	for(auto x : mp){
		if(x.second == val){
			cout<<x.first<<'\n';
		}
	}

	return 0;
}

Measured memory_bytes: 23808
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	Y := scanInt()

	for a := 0; a <= N; a++ {
		for b := 0; b+a <= N; b++ {
			total := 10000*a + 5000*b + 1000*(N-a-b)
			if total == Y {
				fmt.Println(a, b, N-a-b)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 1772
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

string toUpper(string s) {
    string t = s;
    for (int i = 0; i < s.size(); i++) {
        t[i] = toupper(s[i]);
    }
    return t;
}

int main(){
    int cnt = 0;
    string target, source;

    cin >> target;
    target = toUpper(target);

    while(true) {
        cin >> source;
        if (source == "END_OF_TEXT") break;
        source = toUpper(source);
        if (target == source) cnt++;
    }

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3172
#include <algorithm>
#include <cmath>
#include <limits>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

int main() {
  unsigned long long n, m;

  std::cin >> n;
  std::cin >> m;

  std::cout << n * (n - 1) / 2 + m * (m - 1) / 2 << std::endl;

  return 0;
}


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

int dist[52][52][52][52];
int fie[52][52];


int W, H;
int tx, ty;
int kx, ky;

struct A {
  int a;
  int b;
  int c;
  int d;
};

int& acc(A a) {
  return dist[a.a][a.b][a.c][a.d];
}

int dd[] = {1, 0, -1, 0};

A mv(A a, int d) {
  A b = a;
  if(fie[a.a + dd[d]][a.b + dd[d ^ 1]] == 0) {
    b.a = a.a + dd[d];
    b.b = a.b + dd[d ^ 1];
  }
  if(fie[a.c + dd[d ^ 2]][a.d + dd[d ^ 3]] == 0) {
    b.c = a.c + dd[d ^ 2];
    b.d = a.d + dd[d ^ 3];
  }
  return b;
}

int solve() {
  cin >> W >> H;
  if(W == 0 && H == 0) return 0;
  cin >> tx >> ty;
  swap(tx, ty);
  cin >> kx >> ky;
  swap(kx, ky);
  for(int i = 0;i <= H + 1;i++) for(int j = 0;j <= W + 1;j++) fie[i][j] = 1;
  for(int i = 1;i <= H;i++) for(int j = 1;j <= W;j++) cin >> fie[i][j];

  for(auto& w: dist) for(auto& x: w) for(auto& y: x) for(auto& z: y) z = -1;

  queue<A> que;
  que.push({tx, ty, kx, ky});
  acc({tx, ty, kx, ky}) = 0;

  while(!que.empty()) {
    A v = que.front();
    if(v.a == v.c && v.b == v.d) {
      cout << acc(v) << endl;
      return 1;
    }
    que.pop();
    for(int i = 0;i < 4;i++) {
      A u = mv(v, i);
      if(acc(u) == -1) {
        acc(u) = acc(v) + 1;
        que.push(u);
      }
    }
  }
  cout << "NA" << endl;
  return 1;
}

int main() {
  while(solve());
}



Measured memory_bytes: 31800
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;ll d;cin>>n>>d;
    ll x,y;
    int ans=0;
    rep(i,n){
        cin>>x>>y;
        if(x*x+y*y<=d*d)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3612
program arc097_a
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,l,r,k
    character(5000):: s, s_list(5),subs

    read*, s
    read*, k
    s_list(:) = ''
    do i=1,5
        do j=1,k
            s_list(i) = trim(s_list(i)) // 'z'
        end do
    end do
    n = len_trim(s)
    
    do l=1,n
        do r=l,min(l+k,n)
            subs = s(l:r)
            do i=1,5
                if (subs == s_list(i)) exit
                if (subs < s_list(i)) call swap(subs, s_list(i))
            end do
        end do
    end do
    print'(a)', trim(s_list(k))
contains
    subroutine swap(s1,s2)
        character(5000):: s1,s2,tmp
        tmp=s1; s1=s2; s2=tmp
    end subroutine

end program arc097_a

Measured memory_bytes: 640
s = input()
S = len(s)

mod = 10**9+7

#全ての余りを確認する
dp = [[0 for i in range(13)]for j in range(S)]

if s[0] == "?":
    for i in range(10):
        dp[0][i%13] += 1
else:
    dp[0][int(s[0])%13] += 1

for i in range(1,S):
    if s[i] == "?":
        for j in range(10):
            for k in range(13):
                dp[i][(10*k+j)%13] += dp[i-1][k]%mod
    else:
        for k in range(13):
            dp[i][(10*k+int(s[i]))%13] += dp[i-1][k]%mod
            
print(dp[-1][5]%mod)

Measured memory_bytes: 66660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N, M;
    cin >> N;
    M = (N + 1) / 2;
    double ans;
    ans = (double)M / N;

    cout << fixed << setprecision(10) << ans << endl;
    
    return 0;
}


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

#define MAXSZ 50
#define VL 1000000
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  int dp[MAXSZ+1][MAXSZ+1], fld[MAXSZ][MAXSZ];
  int w,h;
  string buf;
  
  cin >> h >> w;
  for (int i=0; i<h; i++){
    cin >> buf;
    for (int j=0; j<w; j++){
      fld[j][i] = buf[j]-'0';
      dp[j][i] = VL;
    }
  }
  dp[0][0] = 0;
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      // 配るDPで書いてみる
      dp[j+1][i] = MIN(dp[j+1][i], dp[j][i]+fld[j+1][i]);
      dp[j][i+1] = MIN(dp[j][i+1], dp[j][i]+fld[j][i+1]);
    }
  }
  /*
  for (int i=0; i<h; i++){
    cout << dp[0][i];
    for (int j=1; j<w; j++){
      cout << dp[j][i];
    } cout << endl;
  }*/
  cout << dp[w-1][h-1] << endl;
  return 0;
}


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

using namespace std;

int main(){
    int N,i;
    int m1,m2;
    m1 = m2 = 0;
    cin >> N;
    vector<int> v(N);
    for(i=0;i<N;i++){
        int A;
        cin >> A;
        v[i] = A;
        if(A>m1){
            m2 = m1;
            m1 = A;
        } else if (A>m2){
            m2 = A;
        }
    }

    for(i=0;i<N;i++){
        cout << (v[i]==m1 ? m2 : m1) << endl;
    }
}


Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <utility>
#define io ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int N=3e5+10;
void solve(){
    int n,m,M;
    cin>>n>>m>>M;
    set<pair<int,int> > s;
    //memset(a,0,sizeof(a));
    for(int i=1;i<=M;i++){
        int a,b;cin>>a>>b;
        s.insert(make_pair(a,b));
    }
    int maxx=0,maxy=0;
    map<int,int> mp1,mp2;
    for(auto i:s){
        mp1[i.first]++;
        mp2[i.second]++;
    }
    int x=0,y=0;
    for(auto i:mp1){
        if(i.second>maxx){
            x=i.first;
            maxx=i.second;
        }
    }
    for(auto i:mp2){
        if(i.second>maxy){
            y=i.first;
            maxy=i.second;
        }
    }
    //cout<<maxx<<" "<<maxy<<"!\n";
    int ans=0,t=0;
    for(int i=1;i<=m;i++){
        t=max(mp2[i],t);
        if(s.count({x,i}))t--;
        ans=max(ans,t);
        //cout<<ans<<"!\n";
    }
    int res=ans+maxx;
    ans=0,t=0;
    for(int i=1;i<=n;i++){
        t=max(mp1[i],t);
        if(s.count({i,y}))t--;
        ans=max(ans,t);
        //cout<<ans<<"!\n";
    }
    cout<<max(res,ans+maxy);
}
int main(){
    io;
    //int T;cin>>T;
    //while(T--)
        solve();
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const int MOD=1000000007;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

struct UnionFind{
	vi par;
	vi rank;

	UnionFind(int n=1){
		init(n);
	}

	// n要素で初期化
	void init(int n=1){
		par.resize(n);
		rank.resize(n);
		REP(i, n){
			par[i]=i;
			rank[i]=0;
		}
	}

	// xの根を求める
	int find(int x){
		if(par[x]==x){
			return x;
		}
		else{
			return par[x]=find(par[x]);
		}
	}

	// xとyが属する集合を併合
	bool unite(int x, int y){
		x=find(x);
		y=find(y);
		if(x==y){
			return false;
		}
		if(rank[x]<rank[y]){
			par[x]=y;
		}
		else{
			par[y]=x;
			if(rank[x]==rank[y]){
				++rank[x];
			}
		}
		return true;
	}

	// xとyが同じ集合に属するか判定
	bool issame(int x, int y){
		return find(x)==find(y);
	}
};

int sz[114514];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	int m, a[114514], b[114514];
	cin>>n>>m;
	REP(i, m){
		cin>>a[i]>>b[i];
		--a[i];
		--b[i];
	}
	REP(i, n){
		sz[i]=1;
	}
	UnionFind uf(n);
	ll ans[114514];
	ans[m-1]=n*(n-1)/2;
	FORR(i, 1, m){
		if(uf.issame(a[i], b[i])){
			ans[i-1]=ans[i];
		}
		else{
			ll asz=sz[uf.find(a[i])], bsz=sz[uf.find(b[i])];
			ans[i-1]=ans[i]-asz*bsz;
			uf.unite(a[i], b[i]);
			sz[uf.find(a[i])]=asz+bsz;
		}
	}
	REP(i, m){
		cout<<ans[i]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MP make_pair
#define endl '\n'
const int mod = 1e9 + 7;
const int MAXN = 3e5 + 5;
const int INF = 0x3f3f3f3f;

int n;
int vis[MAXN];
int ans[MAXN];

int cnt = 0;
vector<pair<int, int> > e[MAXN];
int maxm = 0;

void dfs(int u, int c) {
    if (vis[u]) return;
    vis[u] = 1;
    int id = 1;
    for (int i = 0; i < e[u].size(); i++) {
        int v = e[u][i].first;
        if (id == c) id++;
        if (!vis[v]) {
            ans[e[u][i].second] = id;
            maxm = max(maxm, id);
            dfs(v, id);
            id++;
        }
    }
}

int main(int argc, char* argv[]) {
#ifdef local
    // freopen("in.txt", "r", stdin);
#endif
    scanf("%d", &n);
    int u, v;
    for (int i = 1; i < n; i++) {
        scanf("%d %d", &u, &v);
        e[u].push_back(MP(v, i));
        e[v].push_back(MP(u, i));
    }

    dfs(1, 0);

    printf("%d\n", maxm);
    for (int i = 1; i < n; i++)
        printf("%d\n", ans[i]);
    return 0;
}


Measured memory_bytes: 14208
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, K: int, A: "List[int]", B: "List[int]"):
    a = 0
    a_n = [a]
    for a_i in A:
        a += a_i
        a_n.append(a)

    b = 0
    b_n = [b]
    for b_i in B:
        b += b_i
        b_n.append(b)

    ans = 0
    j = M
    for i, a in enumerate(a_n):
        if a > K:
            break
        while b_n[j] > (K-a):
            j -= 1
        ans = max(ans, i+j)

    return ans


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    print(solve(N, M, K, A, B))

if __name__ == '__main__':
    main()


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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 2e4 + 1;

vector<pair<int, int>> a;
vector<bool> used;
ld sum = 0;
int n;

vector<int> fact;

ld get(int i, int j) {
	ld d1 = abs(a[i].first - a[j].first);
	ld d2 = abs(a[i].second - a[j].second);
	return sqrtl(d1 * d1 + d2 * d2);
}
ld x = 1;
void rec(int last, int cnt) {
	if (cnt == n) return;
	for (int i = 0; i < n; i++) {
		if (!used[i]) {
			used[i] = true;
			if (last != -1) sum += get(last, i) * fact[n - cnt - 1];
			rec(i, cnt + 1);
			used[i] = false;
		}
	}
}

void solve() {
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	fact.resize(n + 1);
	fact[0] = 1;
	for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i;
	used.resize(n);
	rec(-1, 0);
	
	
	cout << sum / fact[n];
}
	

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

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

int main() {
	int n, k; cin >> n >> k;
	vector<int>h(n); for (auto&& x : h)cin >> x;
	sort(h.begin(), h.end());
	long long ans = 0;
	for (int i = 0; i < n - k; i++)ans += h[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main()
{

  int a, b, c;
  int i;
  int dv;

  scanf("%d %d %d", &a, &b, &c);
  dv = 0;
  for(i = a; i <= b; i++){
    if((c % i) == 0){
      dv++;
    }
  }
  printf("%d\n", dv);

  return(0);
}

Measured memory_bytes: 596
n = int(input())

dp = [0]*(n+1)

for i in range(1,n+1):
  x = n//i
  for j in range(1,x+1):
    dp[i*j]+=1
    
sum_div = 0
for i in range(1,n+1):
  sum_div += i*dp[i]
print(sum_div)

Measured memory_bytes: 151628
n=int(input())
a=list(map(int,input().split()))
l=[0]*(10**6+100)
x=0
for m in a:
  l[m]+=1

j=2
#print(l)


while j <10**6+1:
  c=0
  k=1
  while j*k<=10**6+1 :
    if l[j*k]>0:
      c+=l[j*k]
    k+=1

  if c==n:
    print("not coprime")
    exit()
  elif c>1:
    x=1
  j+=1 
  
if x==1:
  print("setwise coprime")
else:
  print("pairwise coprime")
  
    


Measured memory_bytes: 207436
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
using ll = long long;
using namespace std;
int main(){
    int q;
    cin >> q;
    vector<bool> prime(1e5+1,true);
    prime[1]=0;
    vector<int> reg;
    for(int i=2;i<1e5;i++){
        if(prime[i]){
            reg.push_back(i);
            int k=1;
            while(1){
                if((k*i)>1e5)break;
                prime[k*i]=false;
                k++;
            }
        }
    }
   // cout<<reg.size()<<endl;
   vector<int> count(1e5+1);
   count[1]=0;
   //int f=0;
   for(int i=2;i<1e5;i++){
       count[i]=count[i-1];
       if(binary_search(reg.begin(), reg.end(), i)){
           if(binary_search(reg.begin(), reg.end(), (i+1)/2)){
               count[i]++;
           }
       }
   }
   for(int i=0;i<q;i++){
       int l,r;
       cin >> l >> r;
       cout<<count[r]-count[l-1]<<endl;
   }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;
ll i,j,k;
int main(){
    ll n;cin>>n;
    vector<ll> a(n);for(i=0;i<n;i++){cin>>a[i];}
 
    sort(a.begin(),a.end());

    ll key,another,maxi=a[n-1];
    
    another=(a[n-1]+1)/2;

    vector<long long int>::iterator position;
    position=upper_bound(a.begin(),a.end(),another);
    key=distance(a.begin(),position);
    if(a[key-1]!=another){//一致しないとき
        if(a[key]-another<another-a[key-1]){
            another=a[key];
        }else{another=a[key-1];}
    }

    cout<<a[n-1]<<" "<<another<<endl;
       
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define INF 2147483647

struct edge{
    int to,cost;
};
int V,E; 

vector <edge> G[100010];

multimap <int,int> l;


ll d[500010];


void dijkstra(int s){
    fill(d,d+V,INF);
    d[s] = 0;

    l.insert(make_pair(0,s));

    while(l.size() > 0){
        int p = l.begin()->first;
        int v = l.begin()->second;
        l.erase(l.begin());

        if(d[v] < p) continue;

        for(int i = 0;i < G[v].size(); i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                l.insert(make_pair(d[e.to], e.to));
            }
        }
    }
}


int main(){

    int r;
    cin >> V >> E >> r;
    for(int i = 0;i < E; i++){
         edge e;
        int from;
        cin >> from >> e.to >> e.cost;
        G[from].push_back(e);
    }

    dijkstra(r);

    for(int i = 0;i < V; i++){
        if(d[i] != INF) cout << d[i] << endl;
        else cout << "INF" <<endl;
    }
    return 0;
} 

Measured memory_bytes: 15892
#include<iostream>
using namespace std;
int getCost(int w){
 int cost = 1150; // ?¬¬?????????
 for (int i = 11; i <= w; i++ ){
 if ( i <= 20 ) cost += 125; // ?¬¬?????????
 else if ( 30 < i ) cost += 160; // ?¬¬?????????
 else cost += 140; // ?¬¬?????????
 }
 return cost;
}
int main(){
 for( int w; cin >> w && w >= 0; ) {
 cout << 4280 - getCost(w) << endl;
 }
 return 0;
}

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

using namespace std;

void solve(){
    int n;
    cin>>n;
    vector<int> ht(n), dp(n,0);
    for(auto& i:ht)
        cin>>i;
    dp[1] = abs(ht[1]-ht[0]);
    for(int i=2; i<n; ++i){
        dp[i] = min(dp[i-1]+abs(ht[i]-ht[i-1]),dp[i-2] + abs(ht[i]-ht[i-2]));
    }
    cout<<dp[n-1];
    
}

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

    // int t;
    // cin>>t;
    // while(t--)
        solve();
}


Measured memory_bytes: 1024
#include <iostream>
#include<string.h>
using namespace std;

int main(){
    long long a,b,gcd;
    cin>>a>>b;
    long long c= min(a,b);
    for(int i=c;i>0;i--){
        if(a%i==0 && b%i==0){
            gcd=i;
            break;
        }
    }
    cout<<(a*b)/gcd<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 99999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    int k,x;
    cin >> k >> x;
    for(int i=x-k+1;i<x+k-1;i++) cout << i << " ";
    cout << x+k-1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;

int main(){
    string s;cin>>s;
    s.insert(s.begin()+4,' ');
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
ll dp[100100][13];
int main() {
    dp[0][0] = 1;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < 13; ++j) {
            if(s[i] == '?'){
                for (int k = 0; k <= 9; ++k) {
                    (dp[i+1][(10*j+k)%13] += dp[i][j]) %= mod;
                }
            }else{
                int k = s[i] - '0';
                (dp[i+1][(10*j+k)%13] += dp[i][j]) %= mod;
            }
        }
    }
    cout << dp[s.size()][5] << endl;
    return 0;
}

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

using namespace std;

int main(){
	int x = 0;

	int n;
	cin >> n;

	vector<char>s(n);
  int count = 0;
  int ans = 0;
	for(int i = 0;i < n;i++){
	cin >> s[i];
	if(s[i] == 'I') count++;
	else count--;
	ans = max(ans,count);
	}

	cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    string s;
    ll n;
    cin >> n;
    map<char, ll> all;
    vector<map<char, ll> > mp(n);
    rep1(i, n){
        cin >> s;
        rep1(j, s.size()){
            mp[i][s[j]]++;
            all[s[j]]++;
        }
    }
    string ans = "";
    ll add;
    for (auto x: all){
        add = 100;
        rep1(i, n){
            add = min(add, mp[i][x.first]);
        }
        ans += string(add, x.first);
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

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

int main() {
  int A, B, k;
  int X = 0;
  char c;
  cin >> c;
  if((c == 'a')||(c == 'i')||(c == 'u')||(c == 'e')||(c == 'o')){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant";
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
def main():
    n, m = [int(n) for n in input().split()]
    paths = [[] for i in range(n+1)]
    for i in range(m):
        x, y = [int(r) for r in input().split()]
        paths[x].append(y)
    dp = [-1]*(n+1)

    ans = 0
    for i in range(n+1):
        ans = max(ans, dfs(paths, dp, i))
    print(ans-1)
def dfs(paths, dp, n):
    # nから下の最大長
    length = 0
    for p in paths[n]:
        val=0
        if dp[p] != -1:
            val = dp[p]
        else:
            val = dfs(paths, dp, p)
        length = max(length, val)
    length += 1 # pからnまでの一本もしくはnから終点までの一本
    dp[n] = length
    return length

if __name__ == "__main__":
    main()

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

const ll INF = 1e18;
const int MX = 2005;

int main() {
  ll n;
  cin >> n;
  ll a[n],b[n],c[n];
  ll dp[n+1][3];
  rep(i,n) cin >> a[i] >> b[i] >> c[i];
  rep(i,n) rep(j,3) dp[i][j] = 0;
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  rep(i,n){
    dp[i+1][0] = max(dp[i][1]+a[i+1],dp[i][2]+a[i+1]);
    dp[i+1][1] = max(dp[i][0]+b[i+1],dp[i][2]+b[i+1]);
    dp[i+1][2] = max(dp[i][0]+c[i+1],dp[i][1]+c[i+1]);
  }
  ll ans = 0;
  rep(i,3) ans = max(ans,dp[n-1][i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
/*
                IftekharMd.Shishir
                Dept. of Information and Communication Engineering
                University of Rajshahi
                30.05.20
*/

#include<bits/stdc++.h>

#include<iostream>
#include<stdio.h>
#include<vector>
#include<array>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<string>
#include<queue>
#include<sstream>
#include<stdlib.h>
#include<iterator>

#define ll  long long int
#define ull  unsigned long long int
#define f(i,n)  for(i=0;i<n;i++)
#define F(i,n)  for(i=n-1;i>=0;i--)
#define fa(i,a,b)  for(i=a;i<=b;i++)
#define Fa(i,a,b)  for(i=a;i>=b;i--)
#define LT(i,a,n)  f(i,n)cout<<a[i]<<" "; cout<<endl;

#define vec  vector<long long int>
#define vecit  vec::iterator
#define ved  vector<double>
#define st  set<ll>
#define stid  set<ll,greater<ll> >
#define stit  set<ll>::iterator
#define Mst  multiset<ll>
#define Mstid  multiset<ll,greater<ll> >
#define Mstit  multiset<ll>::iterator

#define mpi  map<ll,ll>
#define mps  map<string,ll>
#define mpit  mp::iterator 
#define mpsit  mps::iterator
#define pi  pair<ll,ll>
#define ps  pair<string,ll>

#define ary(x)  array<ll,x>    // a.at        a.fill(x)       a.swap(b)
#define que  queue<ll>               
#define tpl  tuple<ll,ll,ll>    //a=make_tuple(x, y, z)     get<0>(a)

#define pb(x)  push_back(x)
#define pob()  pop_back()
#define all(a)  a.begin(),a.end()
#define sor(a)  sort(a.begin(),a.end())
#define rev(a)  reverse(a.begin(),a.end())
#define ins(a,x)  insert(a.begin(),x)
#define mem(a,x)  memset(a,x,sizeof(a))    // Array filling

#define bs  binary_search
#define lb  lower_bound
#define ub  upper_bound
#define mp  make_pair

#define FastIO  ios::sync_with_stdio(false);cin.tie(nullptr);
#define points(x)  fixed<<setprecision(x)
#define gcd(x,y)  __gcd(x,y)
#define scd(a,x,y)  a/gcd(x,y);
#define nl  cout<<endl;
#define done  return 0

const double PI= 2*acos(0.0);
const long long MOD= 1000000007;

/*----------[ string to integer ]--------------
string str;  int x=0;
stringstream demo(str);
demo >> x;
cout<< x <<endl;
*/

/*----------[ integer to string ]--------------
string name;  int x=345;
stringstream demo;
demo << x;
name=demo.str();
cout<< name <<endl;
*/

using namespace std;

int main()
{
    FastIO;
    ll n,a,b,c;
    cin>>a>>b>>c;
    ll k=max(a,max(b,c));
    ll s=a+b+c;
    if(k==(s-k))
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    done;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int H = scanner.nextInt(), W = scanner.nextInt();
        scanner.nextLine();
        int[][] dist = new int[10][10];
        for (int i = 0; i < 10; i++) {
            dist[i] = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        }

        for (int via = 0; via < 10; via++)
            for (int from = 0; from < 10; from++)
                for (int to = 0; to < 10; to++)
                    if (dist[from][to] > dist[from][via] + dist[via][to]) {
                        dist[from][to] = dist[from][via] + dist[via][to];
                    }

        int ans = 0;
        for (int i = 0; i < H; i++) {
             for (int n: Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray()) {
                 if (n >= 0) {
                     ans += dist[n][1];
                 }
             }
        }

        System.out.println(ans);
    }

}

Measured memory_bytes: 33180
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (l : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    x = toRational l / 3 :: Rational
  print . fromRational $ x ^ 3

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
module Main where

import Debug.Trace

main :: IO ()
main = do
  [a, b] <- map read . words <$> getLine
  --a `traceShow`
  putStrLn $ solve a b


solve :: Int -> Int -> String
solve a b = search (a, 0) b

search :: (Int, Int) -> Int -> String
search (a, b) z
  | a < 0 || b < 0 = "No"
  | c == z = "Yes"
  | c < z = search (a - 1, b + 1) z
  | c > z = "No"
  | otherwise = undefined
  where
    c = a * 2 + b * 4


Measured memory_bytes: 3912
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 6000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int dp[maxn+5][maxn+5];
int a[maxn+5],nxt[maxn+5],last[maxn+5];
int n,ans;

int eq(int x,int y,int z) {return a[x]==a[y] && a[x]==a[z];}

void upd(int &x,int y) {if(x<y) x=y;}

void trans(int x,int y,int now)
{
    if(now>n) return;
    if(now==n) {upd(ans, dp[x][y] + eq(x,y,now)); return;}
    int A=dp[x][y];
    upd(dp[now+1][now], A + eq(x,y,now+2));
    upd(dp[now+2][now], A + eq(x,y,now+1));
    upd(dp[now+2][now+1], A + eq(x,y,now));

    upd(dp[now][x], A + eq(y,now+1,now+2));
    upd(dp[now+1][x], A + eq(y,now,now+2));
    upd(dp[now+2][x], A + eq(y,now,now+1));
    
    upd(dp[now][y], A + eq(x,now+1,now+2));
    upd(dp[now+1][y], A + eq(x,now,now+2));
    upd(dp[now+2][y], A + eq(x,now,now+1));
}

int main()
{
    scanf("%d",&n);
    rep(i,1,n*3) scanf("%d",&a[i]);
    int N=1,base=0; vi tmp;
    tmp.pb(a[1]); tmp.pb(a[2]);
    rep(i,1,n-1) if(!(a[i*3]==a[i*3+1] && a[i*3+1]==a[i*3+2])) N++,tmp.pb(a[i*3]),tmp.pb(a[i*3+1]),tmp.pb(a[i*3+2]); else base++;
    tmp.pb(a[n*3]);
    assert(N*3==(int)tmp.size());
    n=0;
    for(auto x: tmp) a[++n]=x;
    memset(last,63,sizeof last);
    per(i,1,n) nxt[i]=last[a[i]],last[a[i]]=i;

    //rep(i,1,n) rep(j,1,i-1) dp[i][j]=-inf;
    dp[2][1]=0;
    rep(x,1,n) rep(y,1,x-1) 
    {
        trans(x,y,x/3*3+3);
        if(nxt[x]/3*3>x/3*3) trans(x,y,nxt[x]/3*3);
        if(nxt[y]/3*3>x/3*3) trans(x,y,nxt[y]/3*3);
    }
    printf("%d\n",base+ans);
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

const int MAX = 1500;
int cave[MAX][MAX];
int toIndex[1000010];
int dp[MAX][MAX];
int dx[] = {+1,+0,-1,+0};
int dy[] = {+0,-1,+0,+1};

bool isValid(int x,int y) { return 0 <= x && x < MAX && 0 <= y && y < MAX; }

void pre_calc(){
  memset(cave,-1,sizeof(cave));
  int phase = 1;
  int x = MAX/2, y = MAX/2, dir = 0;
  while( phase <= 1000000 ){
    toIndex[phase] = x + y * MAX;
    cave[y][x] = phase++;
    x += dx[dir], y += dy[dir];
    if( cave[y+dy[(dir+1)%4]][x+dx[(dir+1)%4]] == -1 ) ( dir += 1 ) %= 4;
  }
}

const int  MAX_P = 1000010;

bool isntprime[MAX_P+1]; 	
void init(){
  isntprime[0] = isntprime[1] = true;
  int j;	
  for(int i=2;i<= MAX_P;i++)if(!isntprime[i])for(j=2*i;j<=MAX_P;j+=i)isntprime[j] = true;
}


void compute(int limit,int sp){
  memset(dp,-1,sizeof(dp));
  int sx = toIndex[sp] % MAX, sy = toIndex[sp] / MAX;
  dp[sy][sx] = !isntprime[sp];
  int maxi[2] = {0,0};
  if( dp[sy][sx] > maxi[0] ) { maxi[0] = dp[sy][sx], maxi[1] = sp; }
  REP(y,sy,MAX) rep(x,MAX) if( dp[y][x] != -1) {
    for(int dx=-1;dx<=1;dx++){
      int nx = x + dx, ny = y + 1;
      if( !isValid(nx,ny) ) continue;
      if( cave[ny][nx] > limit || cave[ny][nx] == -1 ) continue;
      dp[ny][nx] = max(dp[ny][nx],dp[y][x]+!isntprime[cave[ny][nx]]);
      if( !isntprime[cave[ny][nx]] ) {
        if( dp[ny][nx] > maxi[0] ) { maxi[0] = dp[ny][nx]; maxi[1] = cave[ny][nx]; }
        else if( dp[ny][nx] == maxi[0] ) maxi[1] = max(maxi[1],cave[ny][nx]);
      }
    }
  }
  cout << maxi[0] << " " << maxi[1] << endl;
}

int main(){
  init();
  pre_calc();
  int m,n;
  while( cin >> m >> n, m,n ) compute(m,n);
  return 0;
}

Measured memory_bytes: 23632