akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int a[5][4][11]={0};
  int n,b,f,r,v,cou=0;
  int i,j,k;  
  scanf("%d",&n);
 while(cou<n){  
    scanf("%d%d%d%d",&b,&f,&r,&v);
    a[b][f][r]+=v;
    cou++;
  }
  for(b=1;b<5;b++){
    for(f=1;f<4;f++){
      for(r=1;r<11;r++){
	if(a[b][f][r]<0){
	  a[b][f][r]=0;
	}
	printf(" %d",a[b][f][r]);
      }
      printf("\n");
    }	
    if(b!=4) printf("####################");
    if(b!=4) printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
//A
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

long long i = 0;
long long win = 0;
long long lose = 0;
string S;

int main()
  {
    cin >> S;
    for (i = 0; i < S.length(); i++)
    {
      if (S.at(i) == 'o')
      {
        win++;
      } else{
        lose++;
      }
    }

    if (lose >= 8)
    {
      cout << "NO" << endl;
      return 0;
    }
    cout << "YES" << endl;
    return 0;
  }


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    if (n % 2 == 1) {
        println("No")
        return
    }
    if (s.substring(0 until n / 2) == s.substring(n / 2 until n)) {
        println("Yes")
    } else {
        println("No")
    }

}




Measured memory_bytes: 32020
#include <iostream>
#include <cmath>
#include <algorithm>
/*
for (int i = 0; i < 7; i++) {

	}
*/
using namespace std;

int main()
{
	char day[7][4] = { "SUN" ,"MON","TUE","WED","THU","FRI","SAT"};
	char s[4];
	int n, ans;
	bool flag;

	cin >> s;
	for (int i = 0; i < 7; i++) {
		flag = true;
		for (int j = 0; j < 3;j++) {
			if (s[j] != day[i][j]) {
				flag = false;
			}
		}
		if (flag) {
			n = i;
			break;
		}
	}
	cout << 7-n;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int MAXN = 3e5+5;
const LL INF = 1LL<<30;
const double eps = 1e-9;
const double PI=3.1415926535897932;

vector<int> v[4];
vector<LL> rs[4];

int main(){
	DRII(n,w);
	LL w0=0;
	REP(i,4)rs[i].PB(0);
	REP(i,n){
		DRII(a,b);
		if(i==0)w0=a;
		v[a-w0].PB(b);
	}
	REP(i,4){
		sort(ALL(v[i]),greater<int>());
		for(int j:v[i]){
			rs[i].PB(rs[i].back()+j);
		}
	}
	LL ans=0;
	REP(i1,SZ(rs[0])){
		REP(i2,SZ(rs[1])){
			REP(i3,SZ(rs[2])){
				REP(i4,SZ(rs[3])){
					LL tw=w0*i1+(w0+1)*i2+(w0+2)*i3+(w0+3)*i4;
					if(tw<=w){
						ans=max(ans,rs[0][i1]+rs[1][i2]+rs[2][i3]+rs[3][i4]);
					}
				}
			}
		}
	}
	printf("%lld",ans);
}


Measured memory_bytes: 256
using System;
using System.Reflection;
using System.Linq.Expressions;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder {
    public class Program {
        static int[] getKeys(char delimiter) {
            var Keys = Console.ReadLine().Split(' ');
            int[] Ns = new int[Keys.Length];
            for (int i = 0; i < Keys.Length; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        static void Show<T>(T[,] map) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        static void Show<T>(T[,] map, string delimiter) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + delimiter);
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        static void Show<T>(IEnumerable<T> ts) {
            foreach (var item in ts) {
                Console.Write(item + " ");
            }
            Console.WriteLine();
        }
        static void Show<T>(IEnumerable<T> ts, string delimiter) {
            foreach (var item in ts) {
                Console.Write(item + delimiter);
            }
            Console.WriteLine();
        }
        static void Main() {
            var Keys = getKeys(' ');
            Console.WriteLine(Keys[0] * Keys[1] / 2);
        }
    }
}


Measured memory_bytes: 11092
import numpy as np
n,m=map(int,input().split())
arr=[]
for i in range(n):
    l=[ord(c)-46 for c in input()]
    if l.count(0)==m:
        continue
    arr.append(l)
a=np.array(arr)
a=a.T
b=[]
for i in range(len(a)):
    if list(a[i]).count(0)==len(a[i]):
        continue
    b.append(list(a[i]))
b=list(np.array(b).T)
for l in b:
    for x in l:
        if x==0:
            print(".",end="")
        else:
            print("#",end="")
    print()


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

template <class T>
struct Unionfindw {
  // tree number
  vector<int> par;
  // tree rank
  vector<int> treerank;
  // edge weight
  vector<T> weight;
  const int inf = 2147483647;
  // constructor
  Unionfindw(int n = 1, T initialnum = 0) {
    stree(n + 1, initialnum);
  }
  // make and initialization
  void stree(int n = 1, T initialnum = 0) {
    par.assign(n, -1);
    treerank.assign(n, 0);
    weight.assign(n, initialnum);
  }
  // search root
  int root(int x) {
    if(par[x] < 0) return x;
    int rx = root(par[x]);
    weight[x] += weight[par[x]];
    return par[x] = rx;
  }
  // is same?
  bool issame(int x, int y) { return root(x) == root(y); }
  // calculate weight
  T calcw(int x) {
    root(x);
    return weight[x];
  }
  // add
  // x+w = y
  // already added, return 0
  bool uni(int x, int y, T w = 0) {
    w += calcw(x);
    w -= calcw(y);
    x = root(x);
    y = root(y);
    if(x == y) return 0;
    if(treerank[x] > treerank[y]) swap(x, y);
    if(treerank[x] == treerank[y]) ++treerank[x];
    par[y] -= size(x);
    par[x] = y;
    weight[x] = -w;
    return 1;
  }

  int size(int x) { return -par[root(x)]; }

  // calculate difference between x and y (y-x)
  // if not same tree, return 1
  T calcdiff(int x, int y) {
    if(!issame(x, y)) return inf;
    return calcw(y) - calcw(x);
  }
};

long long n, q;

int main() {
  cin >> n >> q;
  Unionfindw<long long> uf(n);
  for(int i = 0; i < q; ++i) {
    long long c, x, y, z;
    cin >> c >> x >> y;
    if(c) {
      z = uf.calcdiff(x, y);
      if(z == uf.inf)
        cout << "?" << endl;
      else
        cout << z << endl;
    }
    else {
      cin >> z;
      uf.uni(x, y, z);
    }
  }
  return 0;
}



Measured memory_bytes: 5172
#include<bits/stdc++.h>
using namespace std;
int main(){
  #define int long
  int n,a,b,ba,res=0;
  cin>>n;
  string s;
  a=b=ba=0;
  for(int i=0;i<n;++i){
    cin>>s;
    int l=s.length();
    for(int j=0;j<l-1;++j)if(s[j]=='A'&&s[j+1]=='B')res++;
    if(s[0]=='B'&&s[l-1]=='A')ba++;
    else if(s[l-1]=='A')a++;
    else if(s[0]=='B')b++;
  }
  res+=max(ba-1,0L);
  if(a&&ba){
    a--;
    res++;
  }
  if(ba&&b){
    b--;
    res++;
  }
  cout<<res+min(a,b)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string s; cin >> s;
    for(int i=0;i<s.size();i++){
        if(i%2==0) cout << s[i];
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3760
import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int A = in.nextInt();
        int B = in.nextInt();
        if(2*B>A)
        {
            System.out.println(0);
        }
        else
            {
                System.out.println(A-2*B);
            }







        }







    }

















Measured memory_bytes: 35600
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll H, W;
  cin >> H >> W;
  vector<string> A(H);
  vector<vector<ll>> D(H, vector<ll>(W, INF));
  for (int i = 0; i < H; i++) {
    cin >> A[i];
  }
  queue<pair<ll, ll>> q;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A[i][j] == '#') {
        q.push({i, j});
        D[i][j] = 0;
      }
    }
  }
  int step_x[4] = {0, 0, 1, -1};
  int step_y[4] = {1, -1, 0, 0};
  while (!q.empty()) {
    ll cur_x = q.front().first;
    ll cur_y = q.front().second;
    q.pop();
    for (int i = 0; i < 4; i++) {
      ll next_x = cur_x + step_x[i];
      ll next_y = cur_y + step_y[i];
      if (next_x < 0 || next_x >= H || next_y < 0 || next_y >= W) continue;
      if (D[next_x][next_y] != INF) continue;
      D[next_x][next_y] = D[cur_x][cur_y] + 1;
      q.push({next_x, next_y});
    }
  }
  ll ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ans = max(ans, D[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 29136
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll h,w,n,re;
  cin >> h >> w >> n;
  vector<ll> a(n),b(n),ans(10,0);
  vector<P> ab(n);
  set<P> st;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    ab[i] = P(a[i],b[i]);
    st.insert(P(a[i],b[i]));
  }
  re = (h-2)*(w-2);
  sort(ab.begin(),ab.end());
  for(auto [x,y]:ab){
    for(int i=-1;i<=1;i++){
      for(int j=-1;j<=1;j++){
        ll cx = x+i,cy = y+j;
        if(cx-1<0||cy-1<0||cx+1>=h||cy+1>=w){
          continue;
        }
        bool can = true;
        ll cnt = 0;
        for(int vx=-1;vx<=1;vx++){
          for(int vy=-1;vy<=1;vy++){
            auto itr = st.find(P(cx+vx,cy+vy));
            if(itr!=st.end()){
              if((cx+vx<x&&cy+vy==y)||cy+vy<y){
                can = false;
                break;
              }else{
                cnt++;
              }
            }
          }
        }
        if(can){
          ans[cnt]++;
          re--;
        }
      }
    }
  }
  ans[0] += re;
  for(int i=0;i<10;i++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 12700
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/********** TEMPLATE ENDS HERE ***********/

main()
{
	IOS
	
	int n;
	cin >> n;
	
	vi a(n + 1);
	
	for(int i = 1; i < n + 1; i++) 
		cin >> a[i];
 
	vi b = a;
	
	sort(all(b));
	
	int med1 = b[n / 2], med2 = b[n / 2 + 1];
	
	for(int i = 1; i < n + 1; i++) 
	{
		if(a[i] <= med1) 
		{
			cout << med2 << '\n';
		}
		else 
		{
			cout << med1 << '\n';
		}
	}
}

Measured memory_bytes: 3840
import sys

s = input()
t = input()
lenS = len(s)
lenT = len(t)
ans =""
for i in range(lenS-lenT,-1,-1):
  sub = s[i:i+lenT]
  for j in range(lenT):
    if sub[j]!=t[j] and sub[j]!="?":
      break
  else:  
    ans = s[:i]+t+s[i+lenT:]
    ans = ans.replace("?","a")
    print(ans)
    sys.exit()
  continue
print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()

vvi matmul(vvi a, vvi b){
	int n=a.size();
	vvi d(n,vi(n,0));
	rep(i,n)rep(j,n)rep(k,n) d[i][j]|=a[i][k]&b[k][j];
	return d;
}

static map<int,vvi> memo;
vvi matpow(vvi a,int p){
	return memo[p]=memo.find(p)==memo.end()?p%2?matmul(matpow(a,p-1),a):matmul(matpow(a,p/2),matpow(a,p/2)):memo[p];
}

int main(){
	int n,m,a[3];
	while(cin>>n>>m>>a[0]>>a[1]>>a[2]){
		vvi z(n,vi(n,0)), e=z;
		rep(_,m){
			int p,q; cin>>p>>q;
			e[p-1][q-1]=1;
		}
		memo.clear();
		memo[1]=e;

		vector<vvi> d(3);
		rep(p,3) d[p]=matpow(e,a[p]);
		
		vi g(n,0), ng(n,0);
		g[n-1]=1;
		rep(t,1000){
			bool next=0;
			fill(all(ng),0);
			rep(i,n) if(!g[i]){
				bool ok=1,r;
				rep(p,3) [&]{r=0; rep(j,n) r|=(g[j] and d[p][i][j]); ok&=r;}();
				if(ok) ng[i]=next=1;
			}
			if(!next){
				cout<<"IMPOSSIBLE"<<endl;
				break;
			} else if(ng[0]){
				cout<<t+1<<endl;
				break;
			}
			rep(i,n)g[i]|=ng[i];
		}
	}
	return 0;
}



Measured memory_bytes: 3352
import copy

N,M=map(int,input().split())
a=[0]*M
b=[0]*M
bridge=0
for i in range(0,M):
    a[i],b[i]=map(int,input().split())
for i in range(0,M):
    V={1}
    while True:
        X=copy.copy(V)
        v=len(V)
        for j in X:
            for k in range(0,M):
                if a[k]==j and k!=i:
                    V.add(b[k])
                elif b[k]==j and k!=i:
                    V.add(a[k])
        test=len(V)
        if test==N:
            break
        elif test==v:
            bridge+=1
            break
print(bridge)


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n,k;
	cin>>n>>k;
	int t[n],dp[n];
	for(int i=0;i<n;i++){
		cin>>t[i];
		dp[i]=1e9;
	}
	dp[0]=0;
	for(int i=1;i<n;i++)
		for(int j=max(i-k,0);j<i;j++)
			dp[i]=min(dp[i],dp[j]+abs(t[i]-t[j]));
	cout<<dp[n-1];
	
		

}


Measured memory_bytes: 4376
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

//昇順
int acs(const void *a, const void *b)
{
  return *(int *)a - *(int *)b;
}

int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i=0; i<n; i++)
    scanf("%d", a+i);
  qsort(a, n, sizeof(int), acs);
  int cnt = 0, j = a[0], ans = 0;
  for (int i=0; i<n; i++) {
    if (a[i] == j) {
      if (cnt < j) cnt++;
      else ans++;
    } else {
      if (cnt < j)
        ans += cnt;
      cnt = 1;
      j = a[i];
    }
  }
  if (cnt < j)
    ans += cnt;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int A, B, C;
  cin >> A >> B >> C;
  int temp = A + B + C - max({A, B, C}) - min({A, B, C});
  if (temp == C)
    cout << "Yes\n";
  else
    cout << "No\n";
}

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

int main(){
    int count=0,ifcount=0;
    string S;
    cin >> S;
    for(int i=0;i<S.length();i++){
        if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){count++;if(ifcount<count)ifcount=count;}
        else count=0;
    }
    cout << ifcount << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc =  new Scanner(System.in);
		// 2次元の中の個数
		int n = Integer.parseInt(sc.next());
		// 原点からの距離
		double d = Integer.parseInt(sc.next());
		
		int result = 0 ;
		for(int i = 0; i < n; i++) {
			double x = Integer.parseInt(sc.next());
			double y = Integer.parseInt(sc.next());
			double distance = Math.sqrt(x*x + y*y); 
			if (distance <= d) {
				result++;
			}
		}
		System.out.println(result);

	}
}


Measured memory_bytes: 58644
/*input
5 3
2 3 4 5 1
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long long int k;
    cin>>n>>k;
    int arr[n+1];
    int hash[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        hash[i]=0;
    }
    int curr=1;
    hash[curr]=1;
    vector<int> vec;
    vec.push_back(curr);
    while(k>0)
    {
        curr=arr[curr];
        k--;
        if(hash[curr]!=0)
            break;
        vec.push_back(curr);
        hash[curr]=1;
    }
    if(true)
    {
        int index=0;
        vector<int> vec2;
        for(int i=0;i<vec.size();i++)
        {
            if(vec[i]==curr)
            {
                index=i;
                break;
            }
        }
        vec2=vector<int>(vec.begin()+index,vec.end());
        k=k%(vec2.size());
        cout<<vec2[k]<<"\n";
    }
}

Measured memory_bytes: 5944
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define rep(i,n) for(LL i=0;i<n;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n,option) f(i,0,n)cout<<v[i]<<option;
#define all(a) a.begin(),a.end()
#define size(s) ((int)s.size())
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INT_INF 1<<29
#define LL_INF 1LL<<60
#define MOD 10000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<int>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using vpi = vector<pi>;

#pragma endregion


//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;
}

void y_n(bool p) {
	if (p)_y();
	else _n();
}

void Y_N(bool p) {
	if (p) _Y();
	else _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b)*b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion

/************************************************************************/
signed main(void) {
	cin.tie(0); ios::sync_with_stdio(false);

	st s;
	cin >> s;
	vi v;
	for (int i = 0; i < 4; i++) {
		v.push_back(s[i] - '0');
	}

	for (int bit = 0; bit < (1 << 3); bit++) {
		int tmp;
		st ans;
		tmp = v[0];
		ans += (v[0] + '0');
		for (int i = 0; i < 3; i++) {
			if (bit&(1 << i)) {
				tmp += v[i + 1];
				ans += '+';
				ans += (v[i + 1] + '0');
			}
			else {
				tmp -= v[i + 1];
				ans += '-';
				ans += (v[i + 1] + '0');
			}
		}
		if (tmp == 7) {
			cout << ans << "=7";
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁

const ll MX = 1e18; //1(1倍)e(指数)18(10^18)

int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    bool ng = false;
    rep(i, n)
    {
        ll a;
        cin >> a;
        if (a == 0) //0が一個でもあったら
        {
            cout << 0 << endl;
            return 0;
        }
        if (__int128(ans) * a > MX) //0^18を超えたらng=true
        {
            ng = true;
        }
        ans *= a;
    }
    if (ng)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans = 0;
    int now = h[0], domi = 0;
    repSE(i,1,n) {
        if (h[i] <= now) {
            domi ++;
        }
        else {
            chmax(ans, domi);
            domi = 0;
        }
        now = h[i];
    }
    chmax(ans, domi);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
const double PI=atan(1)*4.0;
vector<ll> a,f;ll n,k;
bool ok(ll x)
{
	ll now=0;
	for(int i=1;i<=n;++i)
	{
		if(a[i-1]*f[i-1]<=x)continue;
		ll v=x/f[i-1];
		now+=a[i-1]-v;
		if(now>k)return 0;
	}
	return 1;
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		ll x;scanf("%lld",&x);
		a.push_back(x);
	}
	for(int i=0;i<n;i++)
	{
		ll y;scanf("%lld",&y);
		f.push_back(y);
	}
	sort(a.begin(),a.end());
	sort(f.begin(),f.end(),greater<ll>());
	ll l=0,r=a[n-1]*f[0];
	while(l<=r)
	{
		ll mid=(l+r)/2;
		if(ok(mid))r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",l); 
	return 0;
}

Measured memory_bytes: 4848
#include "bits/stdc++.h"

using namespace std;

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

    int num = X;
    while (true) {
        bool isprime = true;
        int M = int(sqrt(X)) + 1;
        for (int i = 2; i < M; ++i) {
            if (num % i == 0) {
                isprime = false;
                break;
            }
        }
        if (isprime)
            break;
        ++num;
    }
    cout << num << endl;
}


Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int L[550000];
int R[550000];
int a[600][200000+10];
int main()
{
    int n,m,q;
    cin>>n>>m>>q;
    int len[550];
    memset(len,0,sizeof(len));
    for(int i=0;i<m;i++){
        cin>>L[i]>>R[i];
        a[L[i]][len[L[i]]++]=R[i];
    }
    for(int i=1;i<=n;i++){
        sort(a[i],a[i]+len[i]);
        //for(int j=0;j<len[i];j++)
            //cout<<a[i][j]<<" ";cout<<endl;
    }
    for(int i=0;i<q;i++)
    {
        int x,y;
        cin>>x>>y;
        int ans=0;
        for(int j=x;j<=y;j++)
        {
            if(len[j]==0)continue;
            int l=0,r=len[j]-1;
            //cout<<len[j]<<endl;
            int k=upper_bound(a[j],a[j]+len[j],y)-a[j];
           /* while(l<r){
                int mid=(l+r)/2;
                cout<<mid<<" "<<a[j][mid]<<endl;
                if(a[j][mid]<y)l=mid;
                else r=mid;
            }*/
            k--;
            if(a[j][k]<=y)
            ans+=max(0,k+1);
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

int main(){
  int n,a,b;
  bool ans=1,f=0;
  cin>>n>>a;
    
  if(n>2) REP(i,n-1){
    cin>>b;
    if(a<b) f=0;
    else if(a-1==b && !f) f=1;
    else if(a!=b) ans=0;
    a=b;
   }

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

Measured memory_bytes: 256
#ABC121 C
n, m = map(int, input().split())
shops = []
for i in range(n):
    shops.append(list(map(int, input().split())))
shops = sorted(shops)

price = 0
i = 0
while m > 0:
    if m - shops[i][1] >= 0:
        price += shops[i][0] * shops[i][1]
        m -= shops[i][1]
        i += 1
    else:
        price += shops[i][0] * m
        m -= m
print(price)


Measured memory_bytes: 28652
// Aizu Vol-10 1041: Kyudo: A Japanese Art of Archery
// 2017.8.18 bal4u@uu

#include <stdio.h>

int main()
{
	int n, i, s, c;
	while (scanf("%d", &n) && n) {
		for (s = 0, i = n >> 2; i > 0; i--) scanf("%d", &c), s += c;
		printf("%d\n", s);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

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

    LL cnt = 0;
    LL ans = 0;
    LL bit = 0;
    int l = 0;
    for (int r = 0; r < n; r++) {
        while (bit + a[r] != (bit ^ a[r])) {
            bit -= a[l];
            l++;
        }
        bit += a[r];
        ans += r - l + 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll n, k;
    cin >> n >> k;
    cout << min(min(n,
            abs(n - k * (n / k + 1))),
            abs(n - k * (n / k))) << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define ll unsigned long long

const ll MOD = 1000000000000000000;

int main() {
	//入力
	int x;
	cin >> x;

	//処理
	int ans = 0;
	for (int b = 1;b < 1000;++b) {
		for (int p = 2;p < 1000;++p) {
			ll y = pow(b, p);
			if (y <= x) {
				if (ans < y) ans = y;
			}
		}
	}

	//出力
	cout << ans << endl;

	return 0;
}

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

#define loop(n, i) for(int i=0;i<n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;

int main() {
    int n; cin >> n;
    vec<int> A(n);
    loop (n, i) cin >> A[i];

    int ans = 0;
    loop (n, i) {
        while (A[i] % 2 == 0) {
            A[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	int n;
	int a[1001][1000];
	int g[1001];
	int check[1002];
	int day;
	int f;

	int i,j;

	int match;
	int index;


	scanf("%d",&n);

	// プレイヤー番号は下駄をはかせて使う；
	for(i=1;i<n+1;i++){
		g[i] = 0;
		for(j=0;j<n-1;j++){
			scanf("%d",&a[i][j]);
		}
	}

	f = 1;
	day = 0;
	while(f==1){

		f = 0;
		index = 0;
		check[0] = -1;

		for(i=1;i<n+1;i++){
			// g[i]がプレイヤーiの次のゲーム数
	
			match = a[i][g[i]];

			// 番号が大きい方が相手（＝初めての参照）
			if(match > i){
				if(a[match][g[match]] == i){
					check[index] = i;
					check[index+1] = match;
					check[index+2] = -1; //番兵更新
					index += 2;
					f = 1;
				}
			}

		}

		index = 0;
		while(check[index] != -1){
			g[check[index]]++;
			index++;
		};
		day++;
	}
	

	f = 0;
	for(i=1;i<n+1;i++){
		if(g[i] != n-1){
			f = 1;
		}
	}

	if(f==1){
		printf("-1\n");
	}else{
		printf("%d\n",day-1);
	}



	return 0;
}

Measured memory_bytes: 4096
import java.io.*;
public class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		int sum = 100000;
		double debt = sum * 0.05;
		
		for (int i = 0; i < n; i++) {
			sum += debt;
			if (sum % 1000 != 0) {
				sum -= sum % 1000;
				sum += 1000;
			}
			debt = sum * 0.05;
		}
		System.out.println(sum);
	}

}

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

int main() {
    vector<int> abc (5);
    for(int i=0; i<5; i++){
        cin >> abc.at(i);
    }
    int k;
    cin >> k;
    if(abc.at(4) - abc.at(0) > k){
        cout << ":(";
    }
    else{
        cout << "Yay!";
    }
}

Measured memory_bytes: 256
//minimum operations to reach y from x
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long

void solve()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int pos=-1,cnt=0;
	for(int j=0;j<n;j++)
	{
		if(s[j]=='W')
		{
			pos=j;
			break;
		}
	}
	for(int j=0;j<n;j++)
	{
		if(s[j]=='R')
		{
			cnt++;
		}
	}
	if(pos==-1 || cnt==n)
	{
		cout<<0<<endl;
		return;
	}
	int c=0;
	for(int k=0;k<cnt;k++)
	{
		if(s[k]=='W')
		c++;
	}
	//cout<<cnt<<" "<<c<<" ";
	cout<<c<<endl;
}

int main()
{
	int t;
	t=1;
	while(t--)
	solve();
}

Measured memory_bytes: 3720
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();

    let s: Vec<&str> = s.trim().split(" ").collect();

    let (n, a, b): (u32, u32, u32) = (s[0].parse().unwrap(), s[1].parse().unwrap(), s[2].parse().unwrap());
    let mut answer = 0;
    for i in 1..n + 1 {
        let tt = format!("{}", i);
        let tt = tt.chars().map(|c|c.to_digit(10).unwrap());
        let mut t = 0;
        for c in tt {
            t += c;
        }
        if a <= t && t <= b {
            answer += i;
        }
    }

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

Measured memory_bytes: 4352
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {

    string s;
    
    getline(cin, s);
    
    string tmp;
    tmp = s;
    
    for(int i=0; i<s.size(); i++){
        if(s[i]>='A' && s[i]<='Z')
            tmp[i] = tolower(s[i]);
        else if(s[i]>='a' && s[i]<='z')
            tmp[i] = toupper(s[i]);
        else
            tmp[i] = s[i];
    }
    

    cout << tmp << endl;
    
    return 0;
}



Measured memory_bytes: 3176
#include<stdio.h>

int main(){
  int N,D1,D2,counter=0,ans=0;
  scanf("%d",&N);
  for (int i = 0; i < N; i++)
  {
    scanf("%d%d",&D1,&D2);
    if (D1==D2)
    {
      counter++;
      if (counter>=3)
      {
        ans=1;
      }
    }else{
      counter=0;
    }
    
    
  }
  
  ans > 0 ? puts("Yes"): puts("No"); 

  return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i)
#define repc(i,n) for(int i=0;i<=(n);++i)
#define repcn(i,m,n) for(int i=(m);i<=(n);++i)
#define repcd(i,n) for(int i=(n);i>=0;--i)
#define repcnd(i,m,n) for(int i=(n);i>=(m);--i)
#define repc0(i,n) for(i=0;i<=(n);++i)
#define repcn0(i,m,n) for(i=(m);i<=(n);++i)
#define repcd0(i,n) for(i=(n);i>=0;--i)
#define repcnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define p_queue(n) priority_queue<n,vector<n>,greater<n> >
#define PUTLINE cout<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

string str[60];
pair<pint, pint> b[30];

int main() {
	int n, h, w;
	cin >> n;
	while (--n >= 0) {
		cin >> h >> w;
		rep (i, h) cin >> str[i];
		rep (i, 30) {
			b[i].first.first = -1;
			b[i].first.second = -1;
			b[i].second.first = -1;
			b[i].second.second = -1;
		}
		rep (i, h) rep (j, w) {
			if (isupper(str[i][j])) {
				int c = str[i][j] - 'A';
				if (b[c].first.first == -1) {
					b[c].first.first = i;
					b[c].first.second = j;
				}
				chmin(b[c].first.first, i);
				chmax(b[c].second.first, i);
				chmin(b[c].first.second, j);
				chmax(b[c].second.second, j);
			}
		}
		bool update = true;
		while (update) {
			update = false;
			rep (i, 30) {
				if (b[i].first.first == -1) continue;
				bool isbug = true;
				repcn (y, b[i].first.first, b[i].second.first) {
					repcn (x, b[i].first.second, b[i].second.second) {
						if (str[y][x] != i + 'A' && str[y][x] != '?') isbug = false;
					}
				}
				if (isbug) {
					repcn (y, b[i].first.first, b[i].second.first) {
						repcn (x, b[i].first.second, b[i].second.second) {
							str[y][x] = '?';
						}
					}
					b[i].first.first = -1;
					update = true;
				}
			}
		}
		bool safe = true;
		rep (i, 30) {
			if (b[i].first.first != -1) safe = false;
		}
		cout <<(safe ? "SAFE" : "SUSPICIOUS") << endl;
	}
	return 0;
}

Measured memory_bytes: 916
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

struct Info {
	int i;
	double t;
	Info(int id, double td) {
		i = id;
		t = td;
	}
};

bool cmp(Info& a, Info& b) {
	return a.t < b.t;
}

int main() {

	int N;
	cin >> N;

	double T, A;
	cin >> T >> A;

	vector<Info> H(N, Info(0, 0.0));
	for (int i = 0; i < N; i++) {
		cin >> H[i].t;
		H[i].i = i + 1;
		H[i].t = T - H[i].t * 0.006;
		H[i].t = fabs(A - H[i].t);
	}
	
	sort(H.begin(), H.end(), cmp);

	cout << H[0].i << endl;

	return 0;
}



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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

//! [i日めに][a/b/cを選んだときの]=幸福度最大値
ll dp[100005][3];

int main()
{
    int N;
    cin >> N;
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    REP(i, N)
    {
        REP(j, 3)
        {
            int n;
            cin >> n;
            REP(k, 3)
            {
                if (j == k)
                    continue;
                dp[i + 1][j] = std::max(dp[i + 1][j], dp[i][k] + n);
            }
        }
    }
    ll max = 0;
    REP(i, 3)
    {
        max = std::max(max, dp[N][i]);
    }
    cout << max << endl;
    return 0;
}

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

using namespace std;

int main(void){
  string input;
  while(true){
    cin >> input;
    if(input == "0"){
      return 0;
    }

    int s = 0;
    for(int i = 0;i < input.size();++i){
      char c = input[i];
      s += c - 48;
    }

    cout << s << endl;
  }
}



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

int main() {
  string s;
  cin >> s;
  string ans = "AC";
  if (s[0] != 'A') ans = "WA";
  int cnt = 0;
  for (int i = 1; i < s.size(); i++) {
    if ('A' <= s[i] && s[i] <= 'Z') {
      if (i == 1 || i == s.size() - 1 || s[i] != 'C') ans = "WA";
      cnt++;
    }
  }
  if (cnt != 1) ans = "WA";
  cout << ans << endl;
}

Measured memory_bytes: 3520
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    int n;
    cin >> n;
    cout << (n - 2) * 180;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main(void)
{
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> l(n);
    vector<ll> r(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if(i==0) l[i] = a[i];
        if(i>0) l[i] = gcd(l[i-1], a[i]);
    }
    RREP(i, n){
        if(i==n-1) r[i] = a[i];
        if(i<n-1) r[i] = gcd(a[i], r[i+1]);
    }

    ll ans = 0;
    ans = max(l[n-2], r[1]);
    Rep(i, 1, n-1){
        ans = max(ans, gcd(l[i-1], r[i+1]));
    }
    pr(ans);
}

Measured memory_bytes: 2560
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    D = dict()
    W = ["M", "A", "R", "C", "H"]
    for w in W: D[w] = 0
    for _ in range(N):
        S = input().strip("\n")
        if S[0] in W:
            D[S[0]] += 1
    
    ans = 0
    for i in range(3):
        for j in range(i+1, 4):
            for k in range(j+1, 5):
                ans += D[W[i]] * D[W[j]] * D[W[k]]
    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9076
#include <stdio.h>

int main(int argc, const char * argv[])
{

    long long i;
    long long input;
    long long sum = 1;
    
    scanf("%lld",&input);
    for (i = input; i > 0; i--) {
        sum *= i;
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 592
n ,m ,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sa = [0]
sb = [0]

for i in range(n):
    sa.append(sa[i]+a[i])

for i in range(m):
    sb.append(sb[i]+b[i])

ans = 0
j = m

#しゃくとり
for i in range(n+1):
    if sa[i] > k:
        break
    while sa[i]+sb[j] > k:
        j -= 1
    ans = max(ans, i+j)

print(ans)

Measured memory_bytes: 47484
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int ans = 0;
    int n;
    cin>>n;
    ans += 1000 * (n / 500);
    n %= 500;
    // n %= 100;
    // n %= 50;
    // n %= 10;
    // cerr<<n<<endl;
    ans += 5 * (n / 5);
    cout<<ans<<endl;
    
    return 0;
    
}



Measured memory_bytes: 256
# coding:utf-8
k = int(input())
i = 1

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

if k % 7 == 0:
    L = (9 * k) // 7
else:
    L = 9 * k

for j in range(1, L + 1):
    i = (10 * i) % L
    if i == 1:
        print(j)
        exit()
print(-1)


Measured memory_bytes: 9100
import itertools

N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
PRD=list(itertools.product([0,1,2,3], repeat=N))

P=10**5
for i in range(len(PRD)):
    a,b,c=0,0,0
    for j in range(N):
        if PRD[i][j]==1:
            a+=l[j]
        elif PRD[i][j]==2:
            b+=l[j]
        elif PRD[i][j]==3:
            c+=l[j]
    if 0 in [a,b,c]:
        continue
    L=PRD[i]
    Q=abs(A-a)+abs(B-b)+abs(C-c)+(L.count(1)+L.count(2)+L.count(3)-3)*10
    if P>=Q:
        P=Q

print(P)

Measured memory_bytes: 10996
n, k = map(int, input().split())
A = list(map(int, input().split()))
# dp[i] i個の石で手番の時の勝ち負け
dp = [0]*(k+1)
# 貰う
for i in range(1, k+1):
    for j in range(n):
        if i-A[j] < 0:
            continue
        dp[i] = max(dp[i], 1 if dp[i-A[j]] == 0 else 0)
print('First' if dp[k] else 'Second')


Measured memory_bytes: 42476
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.next()
    val b = sc.next()
    var ans = 0
    repeat(a.length) {
        if (a[it] == b[it]) {
            ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 31268