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

#define ll long long
ll V[10000000] = {}, G[10000000] = {};
string S,Sa,Sb,Sc;
ll A = 0,N = 0, K = 0, D = 0,M = 0, sum = 0;
int main(){
cin >> N >> K;
for(int i = 0;i < N;i++)cin >> V[i];
for(int i = 0;i < N;i++){
if(abs(K - V[i]) <= V[i])sum += abs(K - V[i]);
else sum += V[i];
}

cout << sum * 2 << endl;
return 0; 
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
main(){
    string s,t;
    cin >> s >> t;
    if(s.length() > t.length()){
        cout << "GREATER" << endl;
        return 0;
    }
    if(s.length() < t.length()){
        cout << "LESS" << endl;
        return 0;
    }
    if(s > t)cout << "GREATER" << endl;
    if(s < t)cout << "LESS" << endl;
    if(s == t)cout << "EQUAL" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count=0,a1=a;
        while(a1<=c){
            count+=b;
            a1+=a;
        }
        System.out.println(count);
    }
}

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

int main() {
  string x;
    cin >> x;
  if(x == "AAA" ){
    cout << "No" <<endl;
  }
  else if (x == "BBB"){
    cout << "No"<<endl;
  }
	else {
      cout << "Yes" << endl;
    }
  
  
  
}



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

using namespace std;

#define MAX 1000000000

unsigned long long int N;
unsigned long long int A, B;

//inline unsigned long long int h(const unsigned long long int a, const unsigned long long int b) {
//}

void solve() {
  if (B < A) {
    cout << 0 << endl;
    return;
  }
  if (N == 1) {
    cout << (A == B) << endl;
    return;
  }
  const unsigned long long int n = N - 2;
  const unsigned long long int num = B - A;// + 1;

  //cout << h(n, num) << endl;
  cout << n * num + 1 << endl;
}

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

  solve();
  return 0;
}

Measured memory_bytes: 384
var input: string = require('fs').readFileSync('/dev/stdin', 'utf8');
var inputLines: string[] = input.trim().split("\n");
//var parts = inputLines[0].split(" ");

var a = parseInt(inputLines[0]);
var b = parseInt(inputLines[1]);
var h = parseInt(inputLines[2]);
console.log(Math.floor((a + b) * h / 2));

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    vector<ll> d(n);
    rep(i,n) cin >> d[i];
    ll ans = 0;
    rep(i,n){
        FOR(j,i+1,n){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
AizuOnline A0140
Bus Line
*/
#include <stdio.h>

int sequence[]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9};
main()
{
  int from,to;
  int i;
  int cnt;

  scanf("%d",&cnt);
  while(cnt--)
    {
      scanf("%d %d",&from,&to);
      if(from < 6 && to < 6 && from > to)
        for(i=from;i>=to;i--)
          {
            if(i != from)
              printf(" ");
            printf("%d",i);
          }
      else
        { i=0;
          while(sequence[i] != from){i++;}

          do
            {
              if(sequence[i] != from)
                printf(" ");
              printf("%d",sequence[i]);
              i++;
            }
          while(sequence[i] != to);
          printf(" %d",to);
        }
      printf("\n");
    }

return(0);
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

typedef long long LL;

int n;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    int a = n%10;
    if(a == 3) {
        cout << "bon\n";
    } else if(a == 0 || a == 1 || a == 6 || a == 8) {
        cout << "pon\n";
    } else {
        cout << "hon\n";
    }
    
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
//find_by_order() ->  iterator to the k-th largest element (counting from zero)
//order_of_key() ->    the number  items in a set that are strictly smaller than our item aka index in set
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    if(n==0)cout<<1;
    if(n==1)cout<<0;
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(10);
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    vector<vector<int>> a(h, vector<int>(w));
    rep(i, 0, h) cin >> s[i];
    string t;
    rep(i, 0, w) t.push_back('.');

    int lst = -1, cnt = 1;
    rep(i, 0, h) {
        if (t == s[i])
            continue;
        bool b = false;
        rep(j, 0, w) {
            if (s[i][j] == '#')
                if (!b)
                    b = true;
                else
                    cnt++;
            a[i][j] = cnt;
        }
        rep(j, lst + 1, i) a[j] = a[i];
        lst = i;
        cnt++;
    }
    if (lst != h - 1) {
        rep(i, lst + 1, h) a[i] = a[lst];
    }
    rep(i, 0, h) rep(j, 0, w) {
        cout << a[i][j] << ((j != w - 1) ? ' ' : '\n');
    }

    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>

const long long p = 1000000007;

using namespace std;

class Counting {
    unsigned long long p, n;
    vector<long long> invMemo, facMemo, facInvMemo;
public:
    Counting(unsigned long long nn, unsigned long long np) {
        p = np;
        n = nn;
        invMemo.resize(n + 1);
        facMemo.resize(n + 1);
        facInvMemo.resize(n + 1);
        facMemo[0] = 1;
        facMemo[1] = 1;
        facInvMemo[0] = 1;
        facInvMemo[1] = 1;
        invMemo[0] = 0;
        invMemo[1] = 1;
        for (unsigned long long i = 2; i <= n; i++) {
            invMemo[i] = p - (p / i)*invMemo[p%i] % p;
            facMemo[i] = (facMemo[i - 1] * i) % p;
            facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
        }
    }
    unsigned long long fac(unsigned long long k) {
        return facMemo[k];
    }
    unsigned long long facInv(unsigned long long k) {
        return facInvMemo[k];
    }
    unsigned long long choose(unsigned long long n, unsigned long long k) {
        if (!(0 <= k && k <= n))
            return 0;
        return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
    }
    unsigned long long divide(unsigned long long a, unsigned long long b) {
        return (a * invMemo[b]) % p;
    }
    unsigned long long mod(unsigned long long a) {
        a %= p;
        if (a < 0) a += p;
        return a;
    }
    unsigned long long power(unsigned long long a, unsigned long long e) {
        unsigned long long ans = 1;
        for (; e > 0; e /= 2) {
            if (e % 2 != 0)
                ans = ans * a % p;
            a = a*a%p;
        }
        return ans;
    }
};

int main(void) {
    int n, a;
    cin >> n >> a;
    vector<int> x;
    vector<map<long long, long long>> dp;
    x.resize(n);
    dp.resize(n + 1);
    dp[0][0] = 1;
    for(int i = 0; i < n; i++) {
        cin >> x[i];
        x[i] -= a;
    }
    for(int i = 1; i <= n; i++) {
        for(auto it = dp[i - 1].begin(); it != dp[i -1].end(); it++) {
            dp[i][it->first] += it->second;
            dp[i][it->first + x[i - 1]] += it->second;
        }
    }
    cout << dp[n][0] - 1 << endl;
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,count=0;
    cin >> n;
    int a[n],b[n],c[n-1];
    for(int i=0;i<n;++i)
    {
        cin >> a[i];
    }
    for(int i=0;i<n;++i)
    {
        cin >> b[i];
    }
    for(int i=0;i<(n-1);++i)
    {
        cin >> c[i];
    }
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<n;++j)
        {
            if((j+1)==a[i])
            {
                count+=b[j];
                if((a[i-1])==(a[i]-1))
                {
                    count+=c[a[i]-2];
                }
            }
           
        }
    }
    cout << count;
    return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int a, b;
  std::cin >> a >> b;
  int ans = 0, cnt = 1;
  while (cnt < b)
    cnt += a - 1, ans++;
  print(ans);
}


Measured memory_bytes: 256
import collections
import sys
input = sys.stdin.readline

q = int(input())
a = [input().rstrip() for _ in range(q)]

dic = collections.Counter(a)

ma = max(dic.values())
keys = [k for k, v in dic.items() if v == ma]
keys_s = sorted(keys)
for i in keys_s:
    print(i)


Measured memory_bytes: 93908
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
const ll mod = 998244353;
const int N = 1e6+205;
void solve(){
	int n; 
	cin>>n; 
	n = (n+110)/111;
	cout<<n*111<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


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

int main() {
  long long n, ans;
  cin >> n;
  for (int i = 0; i <= n; ++i) {
    if (i * i > n) break;
    ans = i * i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m,k;
	cin >> n >> m >> k;
	vector<ll>a(n);
	vector<ll>b(m);
	ll sum = 0;
	for(int i = 0;i<n;i++) cin >> a[i];
	for(int i = 0;i<m;i++) cin >> b[i];
	int ans = n;
	for(int i = 0;i<n;i++){
        if(sum+a[i]<=k) sum += a[i];
        else {ans = i;break;}
	}
	int maxi = ans;
	deque<int>d;
	for(int i = 0;i<ans;i++){d.push_back(a[i]);}
	for(int i = 0;i<m;i++){
        if(sum + b[i]<=k){
            sum += b[i];
            ans++;
            maxi = max(maxi,ans);
        }
        else if(!d.empty()){sum -= d.back();d.pop_back();ans--;i--;}
        else break;
	}

	cout << maxi;
return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int _gcd = gcd(a, b);
    vector<int> vec;
    for (int i=1; i*i<=_gcd; ++i) {
        if (_gcd%i==0) {
            vec.push_back(i);
            if(_gcd/i != i)
                vec.push_back(_gcd/i);
        }
    }
    sort(vec.begin(), vec.end());
    cout << *(vec.end()-k) << endl;
}


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

public class MainClass
{
	public const long Giri = 1000000007;

	
	public static void Main(string[] args)
	{
		string t = Console.ReadLine();
		if(t=="Sunny")
		{
			Console.WriteLine("Cloudy");
		}
		else if(t=="Cloudy")
		{
			Console.WriteLine("Rainy");
		
		}
		else
		{
			Console.WriteLine("Sunny");
		
		}
		
	}
	
	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}



Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
using System.Linq.Expressions;

static class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private string[] S;
    private void Scan()
    {
        S = Console.ReadLine().Split(' ');
    }

    public void Solve()
    {
        Scan();
        var stack = new Stack<int>();
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == "+")
            {
                int a = stack.Pop();
                int b = stack.Pop();
                int ans = b + a;
                stack.Push(ans);
            }
            else if (S[i] == "-")
            {
                int a = stack.Pop();
                int b = stack.Pop();
                int ans = b - a;
                stack.Push(ans);
            }
            else if (S[i] == "*")
            {
                int a = stack.Pop();
                int b = stack.Pop();
                int ans = b * a;
                stack.Push(ans);
            }
            else
            {
                stack.Push(int.Parse(S[i]));
            }
        }
        Console.WriteLine(stack.Pop());
    }
}

Measured memory_bytes: 10068
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      
      String[] lines = in.readLine().split(" ");
      int[] arr = new int[lines.length];
      int k=0;
      for (String s : lines) {
        arr[k++] = Integer.parseInt(s); 
      }
      Arrays.sort(arr);
      int step=0;
      if(arr[2] - arr[1] > 3) {
        for(; arr[1]+2 < arr[2]; step++) {
          arr[1] += 2;
        }
      }
      if(arr[1] - arr[0] > 3) {
        for(; arr[0]+2 < arr[1]; step++) {
          arr[0] += 2;
        }
      }

      Tuple3 t = new Tuple3(arr[0], arr[1], arr[2], step);

      bfs(t);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private void bfs(Tuple3 t) {
    Deque<Tuple3> que = new ArrayDeque<>();

    que.offer(t);

    Tuple3 cur;
    int step=0;
    while(!que.isEmpty()) {
      cur = que.poll();

      if(cur.isEq()) {
        System.out.println(cur.step);
        return;
      }

      step = cur.step + 1;
      if(cur.e[0] < cur.e[1] && cur.e[0] < cur.e[2])
        que.offer(new Tuple3(cur.e[0]+2, cur.e[1], cur.e[2], step));
      else if(cur.e[1] < cur.e[2])
        que.offer(new Tuple3(cur.e[0], cur.e[1]+2, cur.e[2], step));
      else
        que.offer(new Tuple3(cur.e[0], cur.e[1], cur.e[2]+2, step));

      if(cur.e[0] < cur.e[2] && cur.e[1] < cur.e[2])
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1]+1, cur.e[2], step));
      else if(cur.e[1] < cur.e[0] && cur.e[2] < cur.e[0])
        que.offer(new Tuple3(cur.e[0], cur.e[1]+1, cur.e[2]+1, step));
      else
        que.offer(new Tuple3(cur.e[0]+1, cur.e[1], cur.e[2]+1, step));
      
    }
  }

  class Tuple3 {
    int[] e;
    int step;

    public Tuple3(int a, int b, int c, int step) {
      e = new int[3];
      e[0] = a;
      e[1] = b;
      e[2] = c;
      this.step = step;
    }

    public boolean isEq() {
      return (e[0] == e[1]) && (e[1] == e[2]);
    }
  }
}

Measured memory_bytes: 23252
LARGE = 10 ** 9 + 7


def solve(n, k, a_list):

    # nCk
    nck_list = [0] * (n + 1)
    nck_list[k] = 1
    for i in range(k + 1, n + 1):
        nck_list[i] = (nck_list[i - 1] * i * pow(i - k, LARGE - 2, LARGE)) % LARGE

    # value_counts
    a_cnt_dict = dict()
    for i in range(n):
        a = a_list[i]
        if a not in a_cnt_dict.keys():
            a_cnt_dict[a] = 1
        else:
            a_cnt_dict[a] += 1

    a_list_unique = list(sorted(list(a_cnt_dict.keys())))
    m = len(a_list_unique)
    a_values_cum = [0] * m
    s = 0
    for i in range(m):
        s += a_cnt_dict[a_list_unique[i]]
        a_values_cum[i] = s

    a_list_unique_rev = list(reversed(a_list_unique))
    a_values_cum_rev = [0] * m
    s = 0
    for i in range(m):
        s += a_cnt_dict[a_list_unique_rev[i]]
        a_values_cum_rev[i] = s

    # max
    s_max = 0
    d_max = 0
    for i in range(m):
        c_max = (nck_list[a_values_cum[i]] - d_max) % LARGE
        s_max += a_list_unique[i] * c_max
        s_max %= LARGE
        d_max += c_max
        d_max %= LARGE

    # min
    s_min = 0
    d_min = 0
    for i in range(m):
        c_min = (nck_list[a_values_cum_rev[i]] - d_min) % LARGE
        s_min += a_list_unique_rev[i] * c_min
        s_min %= LARGE
        d_min += c_min
        d_min %= LARGE
    # print(s_max, s_min)
    return (s_max - s_min) % LARGE


def main():
    n, k = map(int, input().split())
    a_list = list(map(int, input().split()))
    res = solve(n, k, a_list)
    print(res)


def test():
    assert solve(4, 2, [1, 1, 3, 4]) == 11
    assert solve(6, 3, [10, 10, 10, -10, -10, -10]) == 360
    assert solve(3, 1, [1, 1, 1]) == 0
    assert solve(10, 6, [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 0, 0, 0, 0, 0]) == 999998537


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 24228
N = int(input())
S = [input() for _ in range(N)]
from collections import Counter
C = Counter(S)
kv = [(k,v) for k,v in C.items()]

m = max(C.values())
ans = [k for k,v in C.items() if v == m]
ans.sort()

for k in ans: print(k)

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vector<pair<int, int>> vp;
  rep(i, n) {
    int x, l;
    cin >> x >> l;
    int L = x - l;
    int R = x + l;
    vp.emplace_back(R, L);
  }
  sort(all(vp));
  int R = -2e9;
  int ans = 0;
  rep(i, n) {
    int r, l;
    tie(r, l) = vp[i];
    if (R <= l) {
      ans++;
      R = r;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1400
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M;
int A[100010];
int dp[100010];
set<int> U;

int DP(int a){
	if(dp[a]!=-1)return dp[a];
	if(U.find(a)!=U.end()){
		return 0;
	}
	if(a>N-1){
		return 0;
	}
	if(a==N-1){
		return 1;
	}
	return dp[a]=(DP(a+1)+DP(a+2))%MOD;
}

signed main(){
	cin>>N>>M;
	REP(i,M){
		cin>>A[i];
		U.insert(A[i]-1);
	}
	REP(i,100010){
		dp[i]=-1;
	}
	int ans=(DP(0)+DP(1))%MOD;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6528
from copy import deepcopy
import bisect
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(k):
    b = [0] * (n+1)
    for i in range(n):
        b[max(0, i-a[i])] += 1
        b[min(n, i+a[i]+1)] -= 1
    for i in range(n-1):
        b[i+1] += b[i]
    b.pop()
    a = deepcopy(b)
    
    if bisect.bisect_left(a, n) == 0: break
    
print(*a)

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

int main()
{
    long int n,i,c,sum;
    n = i = c = sum = 0;
    cin>>n;
    cin>>c;
    long int a[n];

    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }

    sort(a,a+n);

    for(i=0;i<c;i++)
    {
        sum = sum + a[i];
//        cout<<a[i];
    }

    cout<<sum;

    return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> b(n - 1);
    for (int i = 0; i < n - 1; i++) {
        cin >> b[i];
    }
    int ans = 0;
    ans += b[0];
    for (int i = 0; i < n - 1 - 1; i++)
    {
        if (b[i + 1] < b[i])
        {
            ans += b[i + 1];
        } else
        {
            ans += b[i];
        }
    }
    ans += b[n - 1 - 1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int test,m,f,r;
    while(1){
        scanf("%d %d %d",&m,&f,&r);
        test=m+f;
        if(m==-1&&f==-1&&r==-1)
            break;
        else if(m==-1||f==-1)
            printf("F\n");
        else if(test>=80)
            printf("A\n");
        else if(test>=65&&test<80)
            printf("B\n");
        else if(test>=50&&test<65)
            printf("C\n");
        else if(test>=30&&test<50){
            if(r>=50)
                printf("C\n");
            else
                printf("D\n");
        }
        else if(test<30)
            printf("F\n");
    }
    return 0;
}

Measured memory_bytes: 1804
package main

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

var outCnt int
var out bytes.Buffer

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	H := nextInt()
	W := nextInt()
	var f Filed
	f.mas = make([][]int, H)
	for i := 0; i < H; i++ {
		f.mas[i] = nextInts(W)
	}
	for i := 0; i < H; i++ {
		for j := 0; j < W-1; j++ {
			if f.mas[i][j]%2 == 1 {
				f.Move(i, j, i, j+1)
			}
		}
	}
	for i := 0; i < H-1; i++ {
		j := W - 1
		if f.mas[i][j]%2 == 1 {
			f.Move(i, j, i+1, j)
		}
	}
	fmt.Println(outCnt)
	fmt.Print(out.String())
	// log.Print("\n", f.String())
}

type Filed struct {
	mas [][]int
}

func (f *Filed) Move(a, b, c, d int) {
	out.WriteString(fmt.Sprintf("%d %d %d %d\n", a+1, b+1, c+1, d+1))
	outCnt++
	if f.mas[a][b] <= 0 {
		panic("error")
	}
	f.mas[a][b]--
	f.mas[c][d]++
}

func (f Filed) String() string {
	var out bytes.Buffer
	for i := 0; i < len(f.mas); i++ {
		out.WriteString(fmt.Sprintln(f.mas[i]))
	}
	return out.String()
}

type Ans struct {
	y1, x1, y2, x2 int
}

func (a Ans) String() string {
	return fmt.Sprintln(a.y1, a.x1, a.y2, a.y2)
}

type Answer struct {
	s []Ans
}

func (self Answer) Add(a, b, c, d int) {
	self.s = append(self.s, Ans{a, b, c, d})
}

func (self Answer) String() string {
	var out bytes.Buffer
	for i := 0; i < len(self.s); i++ {
		out.WriteString(self.s[i].String())
	}
	return out.String()
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

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

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 14464
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,a;
	cin>>h>>a;
	cout<<(h+a-1)/a<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N =sc.nextInt();
      int L =sc.nextInt();
      
     
      int at[] =new int[N];//りんごの味（L+i-1）
      int pt[] =new int[N];//りんごの味の総和からatをひいた味
      int tt =0;//りんごの味の総和
      //りんごの味の総和を求めている
      for(int i=0; i<N; i++){
        at[i] =L+i;
        tt +=at[i];
      }
	//りんごの味の総和からatをひいた味
      for(int i=0; i<N; i++){
        pt[i] =tt-at[i];
      }
      //全てのりんごN個を使ってできる味とN-1個を使ってできる味の差の初期値
      int diff = 0;
      //求める答え
      int ans =0;
        //差が最小となるところを探す
      for(int i=0; i<N; i++){
        int d0 =Math.abs(tt-pt[i]);
        if(i == 0 || diff>d0){
         	diff =d0;//最小の値を更新していく
         	ans=pt[i];
        }
        
      }
      System.out.println(ans);
    }
}

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

template <class Weight>
struct edge {
	int to;
	Weight cost;
	edge(int t, Weight c) : to(t), cost(c) {}
};

template <class Weight>
using graph = vector<vector<edge<Weight>>>;

template <class Weight>
vector<Weight> spfa(int s, const graph<Weight>& G, const Weight inf) {
	int n = G.size();
	vector<Weight> dist(n, inf);
	vector<bool> on(n);
	queue<int> q;
	dist[s] = 0;
	q.push(s);
	on[s] = true;
	while (!q.empty()) {
		auto v = q.front(); q.pop();
		on[v] = false;
		for (const auto& e : G[v]) if (dist[e.to] > dist[v] + e.cost) {
			dist[e.to] = dist[v] + e.cost;
			if (!on[e.to]) q.push(e.to), on[e.to] = true;
		}
	}
	return dist;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, m, r;
	cin >> n >> m >> r;
	graph<int> G(n);
	for (int i = 0; i < m; i++) {
		int u, v, d;
		cin >> u >> v >> d;
		G[u].emplace_back(v, d);
	}
	const int INF = 1e9;
	auto dist = spfa(r, G, INF);
	for (auto d : dist) {
		if (d == INF) puts("INF");
		else printf("%d\n", d);
	}
	return 0;
}



Measured memory_bytes: 12340
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;



int main()
{
	vector<int> n(3);
	cin >> n[0] >> n[1] >> n[2];

	sort(n.begin(), n.end());

	int ans = 0;

	while (n[1] != n[2]) {
		ans++;
		n[0]++;
		n[1]++;
	}
	if (((n[1] - n[0]) % 2) == 1) {
		ans += (n[1] - n[0]) / 2;
		ans += 2;
	}
	else {
		ans += (n[1] - n[0]) / 2;
	}
	cout << ans << endl;
	
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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


    ll A, B;
    cin >> A >> B;
    A--, B--;
    vector<bool> ans(3, false);
    ans[A] = true;
    ans[B] = true;
    REP(i, 3){
    	if(!ans[i]){
    		cout << i+1 << endl;
    		return 0;
    	}
    }
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
ans = 1
a = -1
if M > 0:
    a = int(input())
    ans = 1
    b = 0
    for i in range(a-1):
        c = ans
        ans = ans + b
        b = c
for i in range(M-1):
    new_ans = 1
    b = 0
    new_a = int(input())
    if new_a == a + 1:
        ans = 0
        break
    k = new_a - a - 2
    for j in range(k):
        c = new_ans
        new_ans = new_ans + b
        b = c
    ans = ans * new_ans % 1000000007
    a = new_a
new_ans = 1
b = 0
for j in range(N - a - 1):
    c = new_ans
    new_ans = new_ans + b
    b = c
ans = ans * new_ans % 1000000007
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main() {
	long long N;
	cin >> N;
	auto num = N % 2 == 0 ? N : N * 2;
	cout << num << endl;

	return 0;
}

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

typedef long long LL;

const int N = 5e5 + 10;

int n, lft[N], rgt[N];
char s[N];

LL cal(LL x){
	return x * (x + 1) / 2;
}

int main(){
	scanf("%s", s);
	n = strlen(s);

	lft[0] = 0;
	for(int i=0; i<n; i++){
		if(s[i] == '<'){
			lft[i+1] = lft[i] + 1;
		} else {
			lft[i+1] = 0;
		}
	}

	rgt[n] = 0;
	for(int i=n-1; i>=0; i--){
		if(s[i] == '>'){
			rgt[i] = rgt[i+1] + 1;
		} else {
			rgt[i] = 0;
		}
	}

	LL ans = 0;
	
	for(int i=1; i<n; i++){
		if(lft[i] && rgt[i]){
			ans = ans + cal(lft[i]-1) + cal(rgt[i]-1) + max(lft[i], rgt[i]);
		}
	}

	ans = ans + cal(lft[n]) + cal(rgt[0]);

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

	return 0;
}


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

using namespace std;

int main(){
    long long n;
    cin>>n;
    vector<vector<long long>> dp(n,vector<long long>(n,numeric_limits<long long>::max()/4));
    vector<pair<long long,long long>> tv(n);
    for (int i = 0; i < n; ++i) {
        long long a,b;
        cin>>a>>b;
        tv[i]=make_pair(b,a);
    }
    sort(tv.begin(),tv.end());
    if(tv[0].second<=tv[0].first)dp[0][0]=tv[0].second;
    for (int i = 1; i < n; ++i) {
        if(tv[i].second<=tv[i].first)dp[i][0]=min(dp[i-1][0],tv[i].second);
        else dp[i][0]=dp[i-1][0];
        for (int j = 1; j <= i; ++j) {
            if(dp[i-1][j-1]+tv[i].second<=tv[i].first){
                dp[i][j]=min(dp[i-1][j-1]+tv[i].second,dp[i-1][j]);
            }
            else dp[i][j]=dp[i-1][j];
        }
    }
    long long ans=-1;
    for (int i = 0; i < n; ++i) {
        if(dp[n-1][i]!=numeric_limits<long long>::max()/4)ans=i;
    }
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 3160
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
 int N;
 cin >> N;
 if(N==1||N==2)cout << 0 <<endl;else cout << N/3 << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	ll sum = 0;
	rep(i, 0, b) {
		sum += a;
		if (sum%b == c) {
			print("YES");
			return 0;
		}
		sum %= b;
	}
	print("NO");
	return 0;
	
}

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

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

  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  vector<vector<int64_t>> max_diff(n, vector<int64_t>(n));
  for (int i = n - 1; i >= 0; i--) {
    for (int j = i; j <= n - 1; j++) {
      if (i == j) {
        max_diff[i][j] = (int64_t)a[i];
      } else {
        max_diff[i][j] = (int64_t)max(a[i] - max_diff[i + 1][j], a[j] - max_diff[i][j - 1]);
      }
    }
  }

  cout << max_diff[0][n - 1] << "\n";
  return 0;
}

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

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

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int x, n; cin >> x >> n;
	vector<int> p(n); cin >> p;

	set<int> ps;
	for(int i=0; i<n; i++) ps.insert(p[i]);

	int dmin = x;
	int ans = 0;
	for(int y=1; y<105; y++){
		if(ps.count(y)) continue;
		if(abs(x-y)<dmin){
			dmin = abs(x-y);
			ans = y;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3644
N = int(input())

cnt = 0
def dfs(s): 
    global cnt
    if int(s) > N:
        return 0 
    if all(s.count(c) > 0 for c in '753'):
        cnt += 1
    for c in '357':
        dfs(s+c)

dfs('0')
print(cnt)

Measured memory_bytes: 2940
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int input = scan.nextInt();
        int A,B,C,D;
        String no;
        D=input%10;
        input/=10;
        C=input%10;
        input/=10;
        B=input%10;
        input/=10;
        A=input%10;

        if(A+B+C+D==7){
            System.out.println(A+"+"+B+"+"+C+"+"+D+"=7");
        } else if(A+B+C-D==7){
            System.out.println(A+"+"+B+"+"+C+"-"+D+"=7");
        } else if(A+B-C+D==7){
            System.out.println(A+"+"+B+"-"+C+"+"+D+"=7");
        } else if(A+B-C-D==7){
            System.out.println(A+"+"+B+"-"+C+"-"+D+"=7");
        } else if(A-B+C+D==7){
            System.out.println(A+"-"+B+"+"+C+"+"+D+"=7");
        } else if(A-B+C-D==7){
            System.out.println(A+"-"+B+"+"+C+"-"+D+"=7");
        } else if(A-B-C+D==7){
            System.out.println(A+"-"+B+"-"+C+"+"+D+"=7");
        } else if(A-B-C-D==7){
            System.out.println(A+"-"+B+"-"+C+""+D+"=7");
        }
    }
}


Measured memory_bytes: 22992
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    x <- getInt
    let ans :: Int
        ans | x <= 599 = 8
            | x <= 799 = 7
            | x <= 999 = 6
            | x <= 1199 = 5
            | x <= 1399 = 4
            | x <= 1599 = 3
            | x <= 1799 = 2
            | x <= 1999 = 1 
    print ans

Measured memory_bytes: 3664
s = gets.chomp.split("")

n = s.length
(n-1).times do |i| 
  if s[i] == s[i+1]
    puts "#{i+1} #{i+2}"
    exit
  end
end

(n-2).times do |i| 
  if s[i] == s[i+2]
    puts "#{i+1} #{i+3}"
    exit
  end
end

puts "-1 -1"

Measured memory_bytes: 6908
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

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

	int n;
	cin >> n;
	vector<ll> v(n);
	map<ll,ll> nr;

	for(int i =0; i< n; ++i)
	{
		
		cin >> v[i];
		nr[v[i]]++;
	}

	ll total = 0;
	for(auto &it : nr)
	{
		total+= 1LL*it.second*(it.second-1) / 2;
	}

	for(int i =0 ;i< n; ++i)
	{
		ll s1 = 1LL*nr[v[i]] * (nr[v[i]]-1) / 2;
		
		ll s2 = max(0LL,nr[v[i]] - 1) * (max(0LL,nr[v[i]]-2)) / 2;
		cout << max(0LL,total - (s1-s2)) << '\n';
	}


    return 0;
}

Measured memory_bytes: 11136
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto N = readln.chomp.to!int;
    auto X = new long[](N);
    auto Y = new long[](N);
    int[][long] Xi;
    int[][long] Yi;
    foreach (i; 0..N) {
        auto s = readln.split.map!(to!long);
        X[i] = s[0];
        Y[i] = s[1];
        Xi[s[0]] ~= i;
        Yi[s[1]] ~= i;
    }

    auto uf = new UnionFind(N);

    foreach (k; Xi.keys) {
        foreach (i; Xi[k])
            uf.unite(i, Xi[k][0]);
    }
    foreach (k; Yi.keys) {
        foreach (i; Yi[k])
            uf.unite(i, Yi[k][0]);
    }

    Tuple!(long, long, int)[] queue;
    auto Xk = Xi.keys.array;
    auto Yk = Yi.keys.array;
    Xk.sort();
    Yk.sort();

    foreach (i; 0..Xk.length.to!int - 1) {
        queue ~= tuple(Xk[i+1], Xk[i], 0);
    }
    foreach (i; 0..Yk.length.to!int - 1) {
        queue ~= tuple(Yk[i+1], Yk[i], 1);
    }

    queue.sort!((a, b) => a[0] - a[1] < b[0] - b[1])();
    long ans = 0;

    foreach (q; queue) {
        if (q[2] == 0) {
            long k1 = q[0];
            long k2 = q[1];
            int i1 = Xi[k1][0];
            int i2 = Xi[k2][0];
            if (uf.find(i1) != uf.find(i2)) {
                ans += k1 - k2;
                uf.unite(i1, i2);
            }
        } else {
            long k1 = q[0];
            long k2 = q[1];
            int i1 = Yi[k1][0];
            int i2 = Yi[k2][0];
            if (uf.find(i1) != uf.find(i2)) {
                ans += k1 - k2;
                uf.unite(i1, i2);
            }
        }
    }

    ans.writeln;
}

class UnionFind {
    int N;
    int[] table;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }
}


Measured memory_bytes: 40572
#include<stdio.h>
#include<string.h>

int main(void){
    int i,c_i,len,count=0;
    char s[11];
    scanf("%s",s);
    len=strlen(s);
    if(s[0]!='A'){
        printf("WA\n");
        return 0;
    }
    for(i=2;i<len-1;i++){
        if(s[i]=='C'&&count==0){
            c_i=i;
            count++;
        }else if(s[i]=='C'&&count==1){
            printf("WA\n");
            return 0;
        }
    }
    if(count==0){
        printf("WA\n");
        return 0;
    }
    for(i=1;i<len;i++){
        if(i!=c_i&&s[i]<97){
            printf("WA\n");
            return 0;
        }
    }
    printf("AC\n");
    return 0;
}


Measured memory_bytes: 128
import scala.io.StdIn.readLine

object Main extends App {
  val Array(n, m) = readLine().split(' ').map(_.toInt)
  val favorites: List[Set[Int]] = (1 to n).map { i =>
    readLine().split(' ').map(_.toInt).toSeq.tail.toSet
  }.toList
  val result = favorites match {
    case (head: Set[Int]) :: tail =>
      tail.foldLeft(head) { case (product, set) =>
        product & set
      }
  }
  println(result.size)
}

Measured memory_bytes: 57892