akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include<math.h>
#include <stdlib.h>
int main(){
  int *n;
  int a,size,i,c;
  int count = 0;
  scanf("%d",&size);
  n = (int *)malloc(size * sizeof(int));

  for(c=0; c<size; c++){
    scanf("%d",&a);
    n[c] = a;
  }
  
  for(i=0;i<c;i++){
    if(isprime(n[i])==1) count++;;
  }
  printf("%d\n",count);
  return 0;
}

int isprime(int x){
  if(x == 2) return 1;
  if(x < 2 || x%2==0) return -1; 
  int i = 3;
  while(i <= sqrt(x)){
    if (x % i ==0) return -1;
    i = i+2;
  }
  return 1;
}



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

class Dictionary {
  vector<int> S;
  const int NIL = -1;
  const int M = 1046527;

  int charCode(char &c) {
    if(c == 'A') return 1;
    if(c == 'C') return 2;
    if(c == 'G') return 3;
    if(c == 'T') return 4;
  }

  int encode(string v) {
    int i = 1;
    int key = 0;
    for(char&c : v) {
      key += charCode(c) * i;
      i *= 5;
    }
    return key;
  }

  int h1(int key) {
    return key % M;
  }

  int h2(int key) {
    return 1 + (key % (M - 1));
  }

  int hash(int key, int i) {
    return (h1(key) + i * (ll) h2(key)) % M;
  }

public:

  Dictionary() {
    S = vector<int>(M, NIL);
  }

  bool insert(string v) {
    int key = encode(v);
    int i = 0;
    while(true) {
      int h = hash(key, i);
      if(S[h] == key) return false;
      if(S[h] == NIL) {
        S[h] = key;
        return true;
      }
      i++;
    }
  }

  bool find(string v) {
    int key = encode(v);
    int i = 0;
    while(true) {
      int h = hash(key, i);
      if(S[h] == NIL) return false;
      if(S[h] == key) return true;
      i++;
    }
  }
};

int main () {
  int n;
  cin >> n;
  Dictionary dic;
  string command, value;
  rep(i,n) {
    cin >> command >> value;
    if(command == "insert") {
      dic.insert(value);
    } else {
      cout << (dic.find(value) ? "yes" : "no") << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 7096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		scan.close();
		int g = gcd(x, y);
		System.out.println(g);
	}
	static int gcd(int n, int m) {
		if(n > m) {
			return gcd(m, n);
		}
		int k = m % n;
		if(k == 0) {
			return n;
		}else {
			return gcd(n, k);
		}
	}
}


Measured memory_bytes: 26324
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int n,i;
	cin>>s;
	for(int t=0;;t++)
	{
		n=n+2;
		for(i=0;i<(s.size()-n)/2;i++)
		{
			if(s[i]!=s[i+(s.size()-n)/2])
			{
				//cout<<t<<" "<<i<<" "<<s[i]<<s[i+(s.size()-n)/2-1]<<endl;
				break;
			}
		}
		if(i==(s.size()-n)/2)
		{
			cout<<s.size()-n;
			return 0;
		}
	}
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;

int a[3];
int main(void)
{
    cin >> a[0] >> a[1] >> a[2];

    sort(a, a + 3);

    int b = a[2] - a[0], c = a[2] - a[1];
    if ((b % 2 == 1 && c % 2 == 0) || (b % 2 == 0 && c % 2 == 1))
        cout << (b - c + 1) / 2 + c + 1 << endl;
    else
        cout << (b - c + 1) / 2 + c << endl;

    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = sorted(LI())
    i = 0
    b = [0]
    for c,i in zip(a,range(n)):
        if i % 2 == 0:
            b.append(c)
        else:
            b.append(24-c)
    b.sort()
    r = a[0]
    for i in range(n):
        if b[i+1] - b[i] < r:
            r = b[i+1] - b[i]

    return r



print(main())




Measured memory_bytes: 5460
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod=1e9+7;
//const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int s,w;
    cin>>s>>w;
    if(w>=s)cout<<"unsafe";
    else cout<<"safe";

    return 0;
}



Measured memory_bytes: 3596
#include<stdio.h>
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int i;
	long long int a[100005];
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	long long int sum = 0;
	for (i = 0; i < n; i++)
		sum += a[i];
	long long int cnt[100005];
	for (i = 0; i < 100005; i++)
		cnt[i] = 0;
	for (i = 0; i < n; i++)
		cnt[a[i]]++;
	long long int q, b, c;
	scanf("%lld", &q);
	for (i = 0; i < q; i++)
	{
		scanf("%lld %lld", &b, &c);
		sum += cnt[b] * (c - b);
		cnt[c] += cnt[b];
		cnt[b] = 0;
		printf("%lld\n", sum);
	}
	return 0;
}

Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
   vector<int>a(n),b(n),c(n-1);//料理、満足度、加算満足度n-1まで
for(int i=0;i<n;i++){
  
    cin>>a.at(i);//1-n
  a.at(i)--;//0-n-1

}
  for(int i=0;i<n;i++){
  cin>>b.at(i);
  }
  for(int i=0;i<n-1;i++){
     cin>>c.at(i);
    
  }
  int p=0;
  for(int i=0;i<n;i++){
    p+=b.at(i);
 
  if(i>0&&a.at(i-1)+1==a.at(i)){//a.at(0)+1=a.at(1)-a.at(n-1)+1=a.at(n)
  p+=c.at(a.at(i-1));//0-n-1
  }
  }
  
  
  cout<<p;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  ll N;
  cin>>N;
  ll A[N];
  rep(i,N){
    cin>>A[i];
  }
  ll ans =0;
  for(int i=0;i<N;i++){
    ans+=A[i]/2;
    if(i==N-1){
      break;
    }
    if(A[i]%2==1&&A[i+1]!=0){
      ans+=1; A[i+1]--;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 1024
//A.cpp
#include <iostream>
#include <string>
using namespace std;

int main(){
  int a[] = {1,3,5,7,8,10,12};
  int b[] = {4,6,9,11};
  int c[] = {2};
  int x,y;
  cin >> x >> y;
  bool fx,fy;
  fx = fy = false;
  for(int i = 0; i < 7; i++){
    if(x == a[i]) fx = true;
    if(y == a[i]) fy = true;
  }
  if(fx&&fy){
    printf("Yes\n");
    return 0;
  }else fx = fy = false;

  for(int i = 0; i < 4; i++){
    if(x == b[i]) fx = true;
    if(y == b[i]) fy = true;
  }
  if(fx&&fy){
    printf("Yes\n");
    return 0;
  }else fx = fy = false;

  for(int i = 0; i < 1; i++){
    if(x == c[i]) fx = true;
    if(y == c[i]) fy = true;
  }
  if(fx&&fy){
    printf("Yes\n");
    return 0;
  }else{
    printf("No\n");
    return 0;
  }



}


Measured memory_bytes: 256
#include <cstdio>
int main()
{
	int n,m,k,i,j;
	scanf("%d%d%d",&n,&m,&k);
	for(i=0;i<=n;i++)
		for(j=0;j<=m;j++)
			if(i*(m-j)+j*(n-i)==k)
			{
				printf("Yes\n");
				return 0;
			}
	printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <queue>

using namespace std;

#define pb push_back
#define pbk pop_back
#define fs first
#define sc second
#define sz(s) ((int) (s).size())
#define all(x) (x).begin(), (x).end()
#define mt make_tuple
#define mp make_pair
#define next hunext
#define prev huprev

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long double ld;

const int inf = 1e9;
const double pi = 4 * atan(1.0);
const double eps = 1e-9;
const int N = int(1e5) + 100;

bool can[N];
int sz[N];

int main() {
#ifdef LOCAL42
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        sz[i] = 1;
    }
    can[0] = true;
    for (int i = 0; i < m; ++i) {
        int x, y;
        scanf("%d %d", &x, &y);
        --x;
        --y;
        if (sz[x] == 0) {
            continue;
        }
        if (!can[x]) {
            --sz[x];
            ++sz[y];
            continue;
        }
        if (sz[x] == 1) {
            can[x] = false;
            can[y] = true;
            sz[x] = 0;
            ++sz[y];
            continue;
        }
        assert(sz[x] > 1);
        can[y] = true;
        --sz[x];
        ++sz[y];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (can[i]) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
const ll limit = 2e9;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}
};

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


int main()
{	
	int x; cin>> x;
	if(x == 1){
		cout<< x;
		return 0;
	}
	
	while(!isprime(x)){
		x++;
	}
	cout<<x;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <functional>
#include <array>
#include <vector>

int main()
{
    int n,k;
    scanf("%d",&n);
    scanf("%d",&k);

    if(n >= k * 2 - 1)
        printf("YES");
    else
        printf("NO");
    
    return 0;
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    A = [0] * N
    for i in range(K):
        input()
        for d in list(map(int, input().split())):
            A[d-1] += 1

    count = 0
    for a in A:
        if a == 0:
            count += 1
    print(count)



if __name__ == '__main__':
    main()

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

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    int ans = 0;
    while (a[0]!=a[1] || a[1]!=a[2] || a[2]!=a[0]) {
        sort(a.begin(), a.end());
        if (a[1] < a[2]) {
            ++a[0];
            ++a[1];
        }
        else a[0] += 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = input()
length = len(n)
n_list = list(n)
ans = ''

for i in range(length):
    if n_list[i] == '1':
        n_list[i] = '9'
    elif n_list[i] == '9':
        n_list[i] = '1'
    ans+=n_list[i]

print(ans)



Measured memory_bytes: 2940
function main(input) {
  var data = input.split("");
  var result = "Good";

  for(i = 0; i < data.length - 1; i++){
    if(data[i] === data[i - 1]){
      result = "Bad";
    }
  }

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

constexpr int inf = 2e9;

int main() {
    int w, h; cin >> w >> h;
    vector<vector<int>> s(h, vector<int>(w));
    vector<vector<int>> hsum(h, vector<int>(w + 1));
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> s[i][j];
        }
    }
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            hsum[i][j + 1] += hsum[i][j] + s[i][j];
        }
    }

    vector<vector<int>> dp(h + 1, vector<int>(w + 1, inf));
    dp[h][w] = 0;
    function<int(int, int)> solve = [&] (int y, int x) {
        assert(y < (int)dp.size() && x < (int)dp[y].size());
        if(dp[y][x] != inf) return dp[y][x];
        const int turn = (y + x) & 1;
        int& res = dp[y][x] = (turn == 0 ? -inf : inf);
        if(y != h) {
            if(turn == 0) res = max(res, solve(y + 1, x) + (hsum[y][w] - hsum[y][x]) - hsum[y][x]);
            else          res = min(res, solve(y + 1, x) + (hsum[y][w] - hsum[y][x]) - hsum[y][x]);
        }
        if(x != w) {
            if(turn == 0) res = max(res, solve(y, x + 1));
            else          res = min(res, solve(y, x + 1));
        }
        return res;
    };

    cout << abs(solve(0, 0)) << endl;
}



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

cards_b = input().split()
cards_s = list(cards_b)

# BubbleSort
for i in range(n):
    for j in range(n - 1, i, -1):
        if int(cards_b[j][1]) < int(cards_b[j - 1][1]):
            cards_b[j], cards_b[j - 1] = cards_b[j - 1], cards_b[j]

#SelectionSort
for i in range(n):
    min_i = i
    for j in range(i, n):
        if int(cards_s[j][1]) < int(cards_s[min_i][1]):
            min_i = j
    cards_s[i], cards_s[min_i] = cards_s[min_i], cards_s[i]

print(" ".join(cards_b))
print("Stable")
print(" ".join(cards_s))

if cards_b == cards_s:
    print("Stable")
else:
    print("Not stable")

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

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline T gcd(T m, T n) {
  if (n == 0)
    return m;
  else
    return gcd(n, std::abs(m) % std::abs(n));
}

#define IOS ios::sync_with_stdio(false), cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vvi;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  IOS;
  constexpr char endl = '\n';

  int X, Y, Z;
  cin >> X >> Y >> Z;
  swap(X, Y), swap(X, Z);

  cout << X << " " << Y << " " << Z << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

int main(){
    IOS;
    in x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " <<y << "\n";
}

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

int main(){
	int n;
	long long soma=0;
	scanf("%d", &n);
	for(int i=1; i<n+1;++i){
		if(i%3==0 || i%5== 0)
			continue;
		else
			soma+=i;
	}
	printf("%lld\n", soma);
    return 0;
}

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

int main()
{
    int x, n; cin >> x >> n;
    int per[101]; memset(per, 0, sizeof(per));
    for (int i = 0; i < n; i++)
    {
        int a; cin >> a;
        per[a] = 1;
    }
    if (per[x] == 0)
    {
        cout << x << '\n';
        return 0;
    }
    int l = 0; int r = 101;
    for (int i = x-1; i > 0; i--)
    {
        if (per[i] == 0)
        {
            l = i;
            break;
        }
    }
    for (int i = x+1; i < 101; i++)
    {
        if (per[i] == 0)
        {
            r = i;
            break;
        }
    }
    if (r-x >= x-l)
    {
        cout << l << '\n';
    }
    else
        cout << r << '\n';
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 1e9 + 7;



string S;

ll N, K, ans = 1;


int main() {

	cin >> N;
	
	cout << N * N * 3 << endl;





	return 0;
}


Measured memory_bytes: 256
h,w,k=map(int,input().split())
s=[list(map(int,list(input()))) for _ in range(h)]

def func(div):
  ret=0
  n_grp=len(div)
  grp=[0]*n_grp
  div.append(h)
  for c in range(w):
    for r in range(h):
      for i in range(n_grp):
        if div[i]<=r<div[i+1]:
          grp[i]+=s[r][c]
    if max(grp)>k:
      ret+=1
      grp=[0]*n_grp
      for r in range(h):
        for i in range(len(div)):
          if div[i]<=r<div[i+1]:
            grp[i]+=s[r][c]
      if max(grp)>k:
        return -1
  return ret

# 縦の分割の仕方はpow(2,h-1)
ans=h*w
for i in range(pow(2,h-1)):
  div=[0]
  for j in range(h-1):
    if ((i>>j) & 1):#立っているビットのところで処理が走る
      div.append(j+1)
  a=func(div)
  #print(a,div)
  if a>-1:
    ans=min(ans,a+len(div)-2)
print(ans)


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

int main()
{
    int K, N;
    vector<int> As;
    cin >> K >> N;
    As.reserve(N);
    copy_n(istream_iterator<int>(cin), N, back_inserter(As));

    vector<int> distances;
    distances.reserve(N);
    std::transform(
        As.begin(), As.end() - 1,
        As.begin() + 1,
        back_inserter(distances),
        [](int a, int b) {
            return b - a;
        });
    distances.push_back(K - As.back() + As.front());

    auto max_distance = *max_element(distances.begin(), distances.end());

    cout << K - max_distance << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
//#pragma gcc optimize("O3")
//#pragma gcc optimize("unroll-loops")
#ifdef EVAH
    #define _WIN32_WINNT 0x0500
    #include<windows.h>
#endif
#define openFile(n) ShellExecute(nullptr,"open",n,nullptr,nullptr,SW_SHOWNORMAL);
#define closeP(n) system((string("taskkill /im ")+n+" /f").c_str());
#define closeConsole PostMessage(GetConsoleWindow(), WM_CLOSE, 0, 0);
#define opf "output.txt"
#define ipf "input.txt"
#define mem(n,x) memset(n,x,sizeof(n));
#define sf scanf
#define pf printf
#define ff first
#define ss second
#define pb push_back
#define PII pair<int,int>
#define For(x,n) for(int i=x; i<n; i++)
#define stv v+2*(mid-tl+1)
#define LL long long int
#define PI acos(-1.0)
#define N 100000000


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    #ifdef EVAH
        //freopen(ipf,"r",stdin);
        //openFile(ipf);
        //closeConsole;
        //freopen(opf,"w",stdout);
    #endif

    LL n,d,x,y,cnt=0;
    cin >> n >> d;
    while(n-- > 0) {
        cin >> x >> y;
        if(sqrt(x*x+y*y)<=d) cnt++;
    }
    cout << cnt << "\n";

    #ifdef EVAH
        //openFile(opf);
        //Sleep(3000);
        //closeP("notepad.exe");
        //closeConsole;
    #endif
}


Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)  cin >> a[i];
    a.push_back(0);
    sort(a.begin(), a.end());
    vector<ll> sum = a;
    for(int i = 1; i <= n; i++)  sum[i] += sum[i-1];
    int m;
    cin >> m;
    vector<ll> b(m);
    for(int i = 0; i < m; i++){
        int x;  cin >> x;
        b[i] = sum[upper_bound(a.begin(), a.end(), x)-a.begin()-1];
    }
    for(int i = 0; i < m; i++){
        ll x;   cin >> x;
        cout << (b[i] >= x ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 9640
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int mod = 1000000007;
inline int qp(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = 1ll * res * a % mod;
		a = 1ll * a * a % mod;
		b >>= 1;
	}
	return res;
}
struct Num {
	int val, e0;
	inline Num(int _v = 0, int _0 = 0): val(_v), e0(_0) {}
	inline Num operator + (const Num &oth) const {
		return Num((val + oth.val) % mod, 0);
	}
	inline Num operator * (const Num &oth) const {
		return Num(1ll * val * oth.val % mod, e0 + oth.e0);
	}
};
int n, a[N];
int Cnt[N], L[N], R[N];
Num D[N], bit[N];
int bit2[N];
inline void add2(int i) {
	while (i <= n) {
		bit2[i]++;
		i += i & -i;
	}
}
inline int sum2(int i) {
	int res = 0;
	while (i > 0) {
		res += bit2[i];
		i -= i & -i;
	}
	return res;
}
inline void add(int i, Num x) {
	while (i <= n) {
		bit[i] = bit[i] + x;
		i += i & -i;
	}
}
inline int sum(int i) {
	Num res;
	while (i > 0) {
		res = res + bit[i];
		i -= i & -i;
	}
	return res.val;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		Cnt[a[i]]++;
	}
	for (int i = n; i >= 1; i--) {
		Cnt[i] += Cnt[i + 1];
	}
	int cp = 1;
	D[0] = 1;
	for (int i = 1; i <= n; i++) {
		Cnt[i] -= n - i;
		if (Cnt[i] < 1) { puts("0"); return 0; }
		cp = 1ll * cp * Cnt[i] % mod;
		Num cur = qp(Cnt[i], mod - 2);
		if (Cnt[i] == 1) cur.e0 = 1;
		else cur = cur * (Cnt[i] - 1);
		D[i] = D[i - 1] * cur;
		if (i == 1 || D[i].e0 != D[i - 1].e0) L[i] = i;
		else L[i] = L[i - 1];
	}
	for (int i = n; i; i--) {
		if (i == n || D[i].e0 != D[i + 1].e0) R[i] = i;
		else R[i] = R[i + 1];
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = (ans + 1ll * (sum(a[i]) - sum(L[a[i]] - 1) + mod) * D[a[i]].val % mod * cp % mod) % mod;
		add(a[i], Num(qp(D[a[i]].val, mod - 2), D[a[i]].e0));
	}
	if (ans & 1) ans += mod;
	ans >>= 1;
	for (int i = 1; i <= n; i++) bit[i] = 0;
	for (int i = 1; i <= n; i++) {
		ans = (ans + 1ll * cp * (i - 1 - sum2(a[i])) % mod) % mod;
		int fuck = 1ll * (sum(R[a[i]]) - sum(a[i]) + mod) * qp(D[a[i]].val, mod - 2) % mod * cp % mod;
		if (fuck & 1) fuck += mod;
		fuck >>= 1;
		ans = (ans - fuck + mod) % mod;
		add(a[i], D[a[i]]);
		add2(a[i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 7296
while True:
    n ,x= list(map(int,input().split()))


    if n == x == 0:
        break
    ans = 0
    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if i + j + k == x:
                    ans += 1
    print(ans)


Measured memory_bytes: 5596
n, k = map(int, input().split())
a = list(map(int, input().split()))
d1, d2 = sorted([q for q in a if q > 0], reverse=True), sorted([q for q in a if q < 0])
C = 1000000007
if len(d1)+len(d2) < k:
    print(0)
elif k == n:
    ans = 1
    for q in a:
        ans = ans*q % C
    print(ans)
elif len(d1) == 0 and k % 2 == 0:
    ans = 1
    for q in range(k):
        ans = ans*d2[q] % C
    print(ans)
elif len(d1) == 0 and len(d2) < n:
    print(0)
elif len(d1) == 0:
    ans = 1
    for q in range(len(d2)-1, len(d2)-k-1, -1):
        ans = ans*d2[q] % C
    print(ans)
elif len(d2) == 0:
    ans = 1
    for q in range(k):
        ans = ans*d1[q] % C
    print(ans)
else:
    ind = 0
    ans, now, w = 0, 0, min(k+1, len(d2)+1)
    for q in range(max(0, (k-len(d1)+1)//2*2), w, 2):
        if now == 0:
            """now = 1
            for q1 in range(q):
                now *= d2[q1]
            for q1 in range(k-q):
                now *= d1[q1]
            ans = now"""
            now, ind = 1, q
        else:
            if d1[k-q+1]*d1[k-q] <= d2[q-2]*d2[q-1]:
                ind = q
    ans = 1
    for q in range(ind):
        ans = ans*d2[q] % C
    for q in range(k-ind):
        ans = ans*d1[q] % C
    print(ans)


Measured memory_bytes: 106356
if __name__ == '__main__':
    x, n = map(int, input().split())
    if n >0:
        a = [int(i) for i in input().split()]
        listN = [i for i in range(-10,110)]
        diffList = list(set(listN) -set(a) )
        ans = 0
        diff = 100
        for i in diffList:
            now = 0
            if i>0:
                now = abs(i-x)
            else:
                now = abs(i)+abs(x)
            if diff > now:
                diff=now
                ans =i
        print(ans)
    else:
        print(x)

Measured memory_bytes: 9212
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;

int32_t main()
{
	int m,k;
	cin>>m>>k;
	if(m==0)
	{
		if(k==0){puts("0 0");}
		else puts("-1");
		return 0;
	}
	if(m==1)
	{
		if(k==0){puts("0 0 1 1");}
		else puts("-1");
		return 0;
	}
	
	if(k>=(1<<m)){puts("-1");return 0;}
	
	for(int i=0;i<(1<<m);i++)
	{
		if(i!=k)cout<<i<<' ';
	}
	cout<<k<<' ';
	for(int i=(1<<m)-1;i>=0;i--)
	{
		if(i!=k)cout<<i<<' ';
	}
	cout<<k<<' ';
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = LI()
    a.sort()
    a, b, c = a
    print(int(str(c)+str(b))+a)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    vector<long long> H(N);
    long long past = 0;
    cin >> past;
    long long MAX = 0;
    long long counta = 0;
    for (int i = 0; i < N - 1; ++i)
    {
        long long tmp;
        cin >> tmp;
        if (past >= tmp)
        {
            counta++;
            MAX = max(MAX, counta);
        }
        else
            counta = 0;
        past = tmp;
    }
    cout << MAX << "\n";
}


Measured memory_bytes: 1024
s = list(input())
s1=s[::-1]
ans = 0
cnt = 0
cnt1 = 0
while cnt<len(s) and cnt1<len(s) and cnt<=len(s)-1-cnt1:
  if s[cnt]!=s1[cnt1]:
    if s[cnt]=="x" and s1[cnt1]!="x":
      cnt+=1
      ans+=1
    elif s1[cnt1]=="x" and s[cnt]!="x":
      cnt1+=1
      ans+=1
    elif s[cnt]!="x" and s1[cnt1]!="x":
      print(-1)
      exit()
  elif s[cnt]==s1[cnt1]:
    cnt+=1
    cnt1+=1
print(ans)



Measured memory_bytes: 4788
private fun getInts(): IntArray {
    return readLine()!!.split(" ").map {it.toInt()}.toIntArray()
}

fun main(){
    val k = getInts()[0]
    val flags = Array(1000000) {i->false}
    var count = 1
    var r = 7

    if (k %2 == 0 || k %5 == 0) {
        print(-1)
        return
    }

    while(true){
        // 割ってみる。
        val quot = r % k
        // もうやった。ループしているから失敗。
        if (flags[quot]) {
            print(-1)
            return
        }
        if (quot == 0) {
            // うまく行った。この値。
            print(count)
            return
        } else {
            // この値はだめだった。カウンタを回し、更新して次へ。
            count++
            flags[quot] = true
            r = quot*10 + 7
        }
    }
}

Measured memory_bytes: 40324
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define Unique(n)        (n).erase(unique(s(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {- 1, 0, 0, 1, 0 };
int dy[] = { 0,- 1, 1, 0, 0 };*/
map<int,bool>mp;
int main()
{
    ios_base::sync_with_stdio(0);
    int n,k;
    cin>>n>>k;
    for(int i=0; i<k; i++)
    {
        int d;
        cin>>d;
        mp[d]=true;
    }
    int ans=0;
    for(int i=n; ;i++)
    {
        bool ok=true;
        int j=i;
        while(j)
        {
            int tmp=j%10;
            if(mp[tmp])
            {
                ok=false;
                break;
            }
            j/=10;
        }
        if(ok)
          return cout<<i,0;
    }
}


Measured memory_bytes: 3616
A,B,M = map(int,input().split())
AA = list(map(int,input().split()))
BB = list(map(int,input().split()))
C = [list(map(int,input().split())) for _ in range(M)]

ans = min(AA)+min(BB)
for x,y,c in C:
  x -= 1
  y -= 1
  ans = min(AA[x]+BB[y]-c,ans)
print(ans)


Measured memory_bytes: 82156
import collections
s = list(input())
tmp = len(set(s))
c = collections.Counter(s).most_common()
if (c[0][1] >= c[-1][1] + 2 and tmp == 3) or (tmp == 2 and len(s) > 2) or (tmp == 1 and len(s) != 1):
    print('NO')
else:
    print('YES')


Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int n, x, y, z;
int dp[2][44][1 << 17], pw[44];
int32_t main()
{
    ios::sync_with_stdio(0);
    cin >> n >> x >> y >> z;
    int a = x + y + z;
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int mask = 0; mask < (1 << a); ++mask)
            for (int d = 1; d <= 10; ++d)
            {
                int new_mask = ((((mask << d) | (1 << (d - 1))) & ((1 << a) - 1)));
                dp[1][i][new_mask] += dp[1][i - 1][mask];
                dp[0][i][new_mask] += dp[0][i - 1][mask];
                if ((new_mask & (1 << (x - 1))) && (new_mask & (1 << (x + y - 1))) && (new_mask & (1 << (a - 1))))
                    dp[1][i][new_mask] += dp[0][i - 1][mask] - dp[1][i - 1][mask];
                dp[0][i][new_mask] %= MOD;
                dp[1][i][new_mask] %= MOD;
            }
    int ans = 0;
    for (int mask = 0; mask < (1 << a); ++mask)
        ans = (ans + dp[1][n][mask]) % MOD;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 41216
MOD = 10**9 + 7


def main():
    N, K = (int(i) for i in input().split())
    g = [0]*(K+1)
    for k in range(1, K+1)[::-1]:
        cnt = K//k
        g[k] += pow(cnt, N, MOD)
        p = k
        while p + k <= K:
            p += k
            g[k] -= g[p]
        g[k] %= MOD
    ans = 0
    for i, g in enumerate(g[1:], start=1):
        ans += i*g
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 72600
#include<stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    int ans = 0;
    int t = 1;
    for(int i=0; i<n; i++){
        if(a[i] == t){
            t++;
        }else{
            ans++;
        }
    }
    if(ans == n){
        printf("-1");
    }else{
        printf("%d", ans);
    }

    return 0;
}

Measured memory_bytes: 896
from collections import Counter

N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

d = Counter(D)
flag = True

for t in T:
    if d[t] == 0:
        flag = False
    else:
        d[t] -= 1
print('YES' if flag else 'NO')

Measured memory_bytes: 41692
def dfs(r, c, g, color):
    s = [r]
    color[r] = c
    while len(s) != 0:
        u = s.pop()
        for i in range(len(g[u])):
            v = g[u][i]
            if color[v] is None:
                color[v] = c
                s.append(v)


def assignColor(n, g, color):
    color_id = 1
    for u in range(n):
        if color[u] is None:
            dfs(u, color_id, g, color)
            color_id += 1


n, m = [int(v) for v in input().split()]
g = [[] for i in range(n)]
for i in range(m):
    s, t = [int(v) for v in input().split()]
    g[s].append(t)
    g[t].append(s)

color = [None] * n
assignColor(n, g, color)

q = int(input())

for i in range(q):
    s, t = [int(v) for v in input().split()]
    if color[s] == color[t]:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 23384
#include <stdio.h>
int main(void)
{
	int a,b, sum,d;
	while(scanf("%d %d", &a, &b)!=EOF)
	{
		d=1;
		sum=a+b;
		while(sum >= 10)
		{
			sum /=10;
			d++;
		}
		printf("%d\n", d);
	}
	return 0;
}

Measured memory_bytes: 600
from itertools import product
N = int(input())

A = {
  i+1 : [
    tuple(map(int, input().split())) for _  in range(int(input()))
  ] for i in range(N)
}


def judge_(joukens, case):
  ans = 1
  for jouken in joukens:
    if case[jouken[0]-1] != jouken[1]:
      ans = 0
    
  return bool(ans)

def judge(case):
  for i in range(N):
    if case[i] == 0:
      continue
    else:
      joukens = A[i+1]
      if judge_(joukens, case):
        continue
      else:
        return False
  
  return True

ans = 0
# 正直者を1、嘘つきを０とする
for case in list(product([1, 0], repeat = N)):
  if judge(case):
    ans = sum(case)
    break
print(ans)

Measured memory_bytes: 8820
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int as[] = new int[n+2];
		as[0] = 0;
		as[n+1] = 0;
		int tot = 0;
		for (int i=1; i<=n; i++) {
			as[i] = scanner.nextInt();
			tot += Math.abs(as[i] - as[i-1]);
		}
		tot += Math.abs(as[n]);
		for (int i=1; i<=n; i++) {
			System.out.println(tot - Math.abs(as[i]-as[i-1]) - Math.abs(as[i+1]-as[i]) + Math.abs(as[i+1] - as[i-1]));
		}
	}

}

Measured memory_bytes: 62616
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var n = Sarray()[0];
            var s = ReadLine();
            if(n%2==1)
            {
                WriteLine("No");
                return;
            }
            var same = true;
            for (var i = 0; i < n/2; i++)
            {
                if (s[i] != s[n/2 + i]) same = false;
            }
            WriteLine(same ?"Yes":"No");
        }
    }
}


Measured memory_bytes: 18892
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int abc [] = new int [3];
        for(int i = 0; i < 3; i++) {
            abc[i] = sc.nextInt();
        }
        Arrays.sort(abc);
        int anser = abc[2]*10 + abc[1] + abc[0];
        System.out.println(anser);
    }
}

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

using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if(abs(a-c) <= d)
        cout << "Yes" << endl;
    else if(abs(a-b) <= d && abs(b-c) <= d)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    Scanner scan = new Scanner(System.in);

    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    int k = scan.nextInt();
    
    
        if (k <= a) {
            System.out.println(k);
        } else if (k > a && k <= a + b) {
            System.out.println(a);
        }  else if (k > a + b && k <= a + b + c) {
            System.out.println(a- (k-a-b));
        } 
    
      


      scan.close();
    }
  }

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

int abs(int a, int b) { return a > b ? a - b : b - a; }
int main() {
    int x, a, b;
    cin >> x >> a >> b;
    cout << (abs(x, a) < abs(x, b) ? "A" : "B") << endl;
    return 0;
}

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

int main() {
	int n;
	scanf("%d", &n);
	vector<int> l(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &l[i]);
	}
	sort(l.begin(), l.end());
	int ans = 0;
	for(int i = 0; i < n - 2; i++) {
		for(int j = i + 1; j < n - 1; j++) {
			int sya;
			sya = l[i] + l[j];
			int right, left, mid;
			left = j;
			right = n;
			while(right - left > 1) {
				mid = (left + right) / 2;
				if(l[mid] >= sya) {
					right = mid;
				}else {
					left = mid;
				}
			}
			ans += max(0, left - j);
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
int main()
{
	long long n, money = 1000, stocks = 0;
	std::cin >> n;
 
	std::vector<long long> day(n);
	for (int i = 0; i < n; i++)
		std::cin >> day[i];
 
	day.resize(std::unique(day.begin(), day.end()) - day.begin());
	day.push_back(day.back());
 
	for (int i = 0; i < (int)day.size() - 1; i++)
		if (day[i] < day[i + 1])
			stocks += money / day[i], money %= day[i];
		else
			money += day[i] * stocks, stocks = 0;
 
	std::cout << money;
}

Measured memory_bytes: 3600
from collections import deque

def bfs(start):
    queue = deque([start])
    visited = []

    while queue:
        label = queue.pop()

        #if label not in visited:
        visited.append(label)

        for v in d[label]:
            if tekazu[v] == float("inf"):
                tekazu[v] = tekazu[label] + 1
                queue.appendleft(v)

    return

n = int(input())
d = [[] for _ in range(n)]

for _ in range(n - 1):
    a, b = map(int, input().split())
    d[a - 1].append(b - 1)
    d[b - 1].append(a - 1)

tekazu = [float("inf") for _ in range(n)] # nは頂点数
tekazu[0] = 0
bfs(0)
tekazu_Fennec = tekazu

tekazu = [float("inf") for _ in range(n)] # nは頂点数
tekazu[-1] = 0
bfs(n - 1)
tekazu_Snuke = tekazu

Fennec = 0
Snuke = 0

for i in range(n):
    if tekazu_Fennec[i] <= tekazu_Snuke[i]:
        Fennec += 1
    else:
        Snuke += 1

#print(tekazu_Fennec, tekazu_Snuke)

if Fennec > Snuke:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 32420
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int r;
        if (a < b) {
            r = b - (a + w);
        } else {
            r = a - (b + w);
        }
        System.out.println(r < 0 ? 0 : r);
    }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define pi 3.1415926535897
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define mod1 998244353
#define inf 1000000000000000000
#define inf1 1000000000
#define endl '\n'
ll n,d;
ll num[10005];
ll dp[10005][100][2];
ll recurse(ll pos,ll rem,ll bound)
{
	if(dp[pos][rem][bound]!=-1)
		return dp[pos][rem][bound];
	ll lim=((bound==0)?num[pos]:9);
	if(pos==n-1)
	{
		ll ans=0;
		for(ll k=0;k<=lim;k++)
			ans+=((k%d==rem)?1:0);
		return dp[pos][rem][bound]=ans;
	}
	ll ans=0;
	for(ll k=0;k<=lim;k++)
	{
		ll new_rem=(rem-k)%d;
		new_rem=(new_rem+d)%d;
		ll new_bound=bound;
		if(!bound && k<num[pos])
			new_bound=1;
		ans=(ans+recurse(pos+1,new_rem,new_bound))%mod;
	}
	return dp[pos][rem][bound]=ans;
}
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	string s;
	getline(cin,s);
	cin>>d;
	for(ll i=0;i<s.length();i++)
		num[i]=(ll)s[i]-(ll)'0';
	n=s.length();
	memset(dp,-1,sizeof(dp));
	ll ans=recurse(0,0,0);
	ans=(ans-1)%mod;
	ans=(ans+mod)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 16768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int earliest = 1200;
		for(int i = 1; i <= 9; i++) {
			int j = i * 111;
			if(N <= j && j < earliest) {
				earliest = j;
			}
		}
		System.out.println(earliest);
	}

}


Measured memory_bytes: 21588
data class Xy(val x: Int, val y: Int) {
    constructor(xy: List<Int>): this(xy[0], xy[1])
}
fun main(args: Array<String>) {
    val N = nextInt()
    val XY = Array(N) { Xy(listOfInt()) }
    val A = IntArray(N)
    var count = 0.0
    var sum: Double = 0.0
    fun D(n: Int, m: Int): Double {
        val dx = Math.abs(XY[n].x - XY[m].x).toDouble()
        val dy = Math.abs(XY[n].y - XY[m].y).toDouble()
        return Math.sqrt(dx * dx + dy * dy)
    }
    fun P(n: Int) {
        if (n == N) {
            count += 1
            for (m in 0 until N - 1) {
                sum += D(A[m], A[m + 1])
            }
        } else {
            for (m in 0 until N) {
                if (A.slice(0 until n).all { it != m }) {
                    A[n] = m
                    P(n + 1)
                }
            }
        }
    }
    P(0)
    val ans = sum / count
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 58852
#include <cstdio>
#include <algorithm>
#include <iostream>
#define int long long
using namespace std;
int m,xyq=998244353;
int dp[310][91000],dp2[310][91000];
int sum,l,ban;
int qm(int aa,int b)
{
	if(b==0)
	{
		return 1;
	}
	if(b==1)
	{
		return 3;
	}
	if(aa%2==1)
	{
		return (qm(aa,b-1)%xyq*aa)%xyq;
	}
	int zx=qm(aa,b/2);
	return (zx%xyq)*(zx%xyq);
}
signed main()
{
cin>>m;
dp[0][0]=1;
dp2[0][0]=1;
for(int x=0;x<m;x++)
{
	cin>>l;
	sum+=l;
	for(int y=0;y<=90000;y++)
	{
		if(dp[x][y])
		{
			dp[x+1][y+l]+=dp[x][y];
			dp[x+1][y+l]%=xyq;
			dp[x][y]*=2;
			dp[x][y]%=xyq;
			dp[x+1][y]+=dp[x][y];
			dp[x+1][y]%=xyq;
		}
	}
	for(int y=0;y<=90000;y++)
	{
		if(dp2[x][y])
		{
			dp2[x+1][y+l]+=dp2[x][y];
			dp2[x+1][y+l]%=xyq;
			dp2[x][y]%=xyq;
			dp2[x+1][y]+=dp2[x][y];
			dp2[x+1][y]%=xyq;
		}
	}
}
ban=(sum+1)/2;
long long l1=0,l2=0;
for(int x=ban;x<=sum;x++)
{
	l1+=dp[m][x];
	l1%=xyq;
}
if(sum%2==0)
{
	l2=dp2[m][sum/2];
}
int d=(xyq+l1-l2)*3%xyq;
int z=qm(3,m);
cout<<(z-d+xyq)%xyq<<endl;

}




Measured memory_bytes: 430336
n,m=map(int,input().split())
num=[0 for i in range(n)]
for i in range(m):
  s,c=map(int,input().split())
  if s>n:
    num[0]=-1
  if n>1 and s==1 and c==0:
    num[0]=-1
  elif num[s-1]==0 or num[s-1]==c:
    num[s-1]=c
  else:
    num[0]=-1 
if num[0]==0:
  if n>1:
    num[0]=1
#print('    ',num)
moji=''
if min(num)>=0:  
  for i in range(n):
    moji+=str(num[i])
  print(int(moji))
else:
  print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;
int main(void){
    string a,b;
    cin>>a>>b;
    if(a.size()>b.size()){
        cout<<"GREATER"<<endl;
    }else if(a.size()<b.size()){
        cout<<"LESS"<<endl;
    }else if(a>b){
        cout<<"GREATER"<<endl;
    }else if(a<b){
        cout<<"LESS"<<endl;
    }else{
        cout<<"EQUAL"<<endl;
    }
    return 0;
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
	ll x,y;
	cin>>x>>y;
	rep(i,0,x+1){
		int j=x-i;
		if(i*2+j*4==y){
			cout<<"Yes"<<en;
			return;
		}
	}
	cout<<"No"<<en;
}

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

	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int A,B,C,D;

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

    int left = A + B;
    int right = C + D;
    if(left > right) cout << "Left" << endl;
    else if(right > left) cout << "Right" << endl;
    else cout << "Balanced" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int calc(int w){
	int money=1150;
	if(w>30){
		money+=(w-30)*160+10*140+10*125;
	}else if(w>20){
		money+=(w-20)*140+10*125;
	}else if(w>10){
		money+=(w-10)*125;
	}
	return money;
}
int main(){
	int w;
	while(cin>>w){
		if(w==-1)break;
		cout<<(4280-calc(w))<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0