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

int main() {
    long n, m, cnt = 0;;
    long zaiko[100002] = {};
    for (long i=0; i<100002; i++)
        zaiko[i] = 1;
    int aka[100002] = {0};
    aka[1] = 1;
    scanf("%ld %ld", &n, &m);
    for (long i=0; i<m; i++) {
        long x, y;
        scanf(" %ld %ld", &x, &y);
        zaiko[x] = zaiko[x] - 1;
        zaiko[y] = zaiko[y] + 1;
        if (aka[x]) {
            aka[y] = 1;
            if (zaiko[x] == 0) {
                aka[x] = 0;
            }
        }
    }
    for (long i=1; i<=n; i++)
        if (aka[i])
            cnt++;
    printf("%ld\n", cnt);
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  string s;
  cin >> s;
  map <char, int> mp;
  REP(i,s.size()){
    mp[s[i]]++;
  }

  bool ok = true;
  for(auto x: mp) {
    if(x.second%2 != 0) ok = false;
  }

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

#define MAX 100000

int partition(int A[], int p, int r) {
    int x = A[r];
    int i = p - 1;
    int tmp;
    for (int j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    tmp = A[i+1];
    A[i+1] = A[r];
    A[r] = tmp;
    return i+1;
}

int main() {
    int A[MAX], n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    int q = partition(A, 0, n-1);

    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        if (i == q) {
            cout << "[" << A[i] << "]";
        } else {
            cout << A[i];
        }
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3388
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    ll N;
    cin >> N;
    if(N%2==1)
        cout << N*2 << endl;
    else cout << N << endl;
}

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

//エラトステネスのふるい(素数発見アルゴリズム)
vector<int> SOE(int min, int max)
{
    //0,1は含まれない
    if (min < 2) min = 2;
    //探索リスト作成
    vector<int> int_array;
    for (int i = min; i <= max; i++) int_array.push_back(i);
    //素数リスト
    vector<int> sosu;
    //√max
    double stop = sqrt(max);
    //計算
    while (true)
    {
        //素数リストに追加
        sosu.push_back(int_array.front());
        int_array.erase(int_array.begin());
        //停止
        if (stop < (double)(sosu.back())) break;
        //ふるい
        for (int i = 0; i < (int)int_array.size(); i++)
        {
            if (int_array[i] % sosu.back() == 0)
                int_array.erase(int_array.begin() + i);
        }
    }
    sosu.insert(sosu.end(), int_array.begin(), int_array.end());
    return sosu;
}

//最小公倍数
int MinCM(int a, int b)
{
    int c = a * b;
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return c / b;
}

//最大公約数
int MaxCD(int a, int b)
{
//入れ替え
    if (a < b)
        swap(a, b);
    int r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
//iget cin int 2 vector
vector<int> igets(int N){
    vector<int> A;
    int temp;
    for (int i = 0; i < N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }
    return A;
}

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

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

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

Measured memory_bytes: 764
S = input()
L = len(S)
odd = "RUD"
even = "LUD"
for i in range(L):
  if (i+1)%2 != 0:
    if S[i] not in odd:
      print("No")
      exit()
  else:
    if S[i] not in even:
      print("No")
      exit()
print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define OUT(x) cout << (x) << endl;
#define ALL(v) v.begin(), v.end()
#define REP(i, n) for (int i=0; i<(int)(n); ++i)
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

const int MAX_X=50, 
          MAX_Y=50;
const ll INF = 10e9;

int N;
int a[200010];
int target;

int main() {
    int A, B; cin >> A >> B;
    if(A==1){
        A+=20;
    }
    if(B==1){
        B+=20;
    }
    string ans;
    if(A > B) ans = "Alice";
    if(A == B) ans = "Draw";
    if(A < B) ans = "Bob";
    cout << ans << endl;
}

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

int main() {
  int m, f, r;
  cin >> m >> f >> r;
  while(m != -1 || f != -1 || r != -1) {
    if (m == -1 || f == -1) {
      cout << "F" << endl;
      cin >> m >> f >> r;
      continue;
    }
    int sum = m + f;
    if (sum >= 80) {
      cout << "A" << endl;
    } else if (sum >= 65) {
      cout << "B" << endl;
    } else if (sum >= 50) {
      cout << "C" << endl;
    } else if (sum >= 30) {
      if (r >= 50) {
        cout << "C" << endl;
      } else {
        cout << "D" << endl;
      }
    } else {
      cout << "F" << endl;
    }

    cin >> m >> f >> r;
  }
}



Measured memory_bytes: 3112
#include <stdio.h>

#define MOD 1000000007
int n;
int dp[220000] = {1};
int memo[220000];
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		int c;
		scanf("%d", &c);
		if(memo[c] == 0 || memo[c] == i - 1){
			dp[i] = dp[i - 1];
		}else{
			dp[i] = (dp[i - 1] + dp[memo[c]]) % MOD;
		}
		memo[c] = i;
	}
	printf("%d\n", dp[n]);
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<set>
#include<cmath>
#include<stack>
#include<random>
using namespace std;

int main(){
    int a[100001],b[100001],c[100001];
    int a_[100001],b_[100001],c_[100001];//index日目にaを使った最大値
     
    int n;
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    a_[1] = a[1];
    b_[1] = b[1];
    c_[1] = c[1];
    for(int i=2;i <=n;i++)
    {
        a_[i] = a[i] + max(b_[i-1],c_[i-1]);
        b_[i] = b[i] + max(a_[i-1], c_[i-1]);
        c_[i] = c[i] + max(a_[i-1], b_[i-1]);
    }
    cout <<  max(a_[n],max(b_[n],c_[n])) << endl;
    
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

struct edge{
 ll to,cost;
};

ll n;
vector<edge> g[100010];
vector<int> ans(100010,-1);

void dfs(int v){
  for(auto itr:g[v]){
        if(ans[itr.to]>=0) continue;
        if(itr.cost%2==0){
          //flag=true;
          ans[itr.to]=ans[v];
          dfs(itr.to);
        }else{
          if(ans[v]==0){
            ans[itr.to]=1;
            dfs(itr.to);
          }else{
            ans[itr.to]=0;
            dfs(itr.to);
          }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n-1){
      ll u,v,w;
      cin>>u>>v>>w;
      g[u].push_back({v,w});
      g[v].push_back({u,w});
    }
    ans[1]=0;
    /*
    FOR(i,1,n+1){
      //bool flag=false;
      for(auto itr:g[i]){
        if(ans[itr.to]>=0) continue;
        if(itr.cost%2==0){
          //flag=true;
          ans[itr.to]=ans[i];
        }else{
          if(ans[i]==0){
            ans[itr.to]=1;
          }else{
            ans[itr.to]=0;
          }
        }
      }
    }
    */
   dfs(1);
    FOR(i,1,n+1){
      cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 9088
S = str(input())

str_data = list(S)

jdg_flag = 0

for i in range(0,len(str_data),2):
  if str_data[i] == 'L':
    jdg_flag = 1
    
for i in range(1,len(str_data),2):
  if str_data[i] == 'R':
    jdg_flag = 1
    
if jdg_flag == 0:
  out = 'Yes'
else:
  out = 'No'

  
print(out)

Measured memory_bytes: 3064
h, w = map(int, input().split())

s = []
for i in range(h):
	t = input()
	s.append(t)

dx = [0,0,1,-1,1,1,-1,-1]
dy = [1,-1,0,0,1,-1,1,-1]

ans = []
for i in range(h):
	v = ""
	for j in range(w):
		if s[i][j] == "#":
			v += "#"
		else:
			c = 0
			for k in range(8):
				x = i + dx[k]
				y = j + dy[k]
				if x < 0 or x >= h or y < 0 or y >= w:
					continue
				if s[x][y] == "#":
					c += 1
			v += str(c)
	ans.append(v)

for i in range(h):
	print (ans[i])

Measured memory_bytes: 3064
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String[] s = new String[n];
    long ans = 1;

    for(int i = 0; i < n; i++){
      s[i] = sc.next();
    }

    Arrays.sort(s);

    for(int i = 0; i < n - 1; i++){
      if(s[i].equals(s[i + 1])){
        ans -= 1;
      }
      ans += 1;
    }

    System.out.println(ans);
  }
}


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

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

    int F[N][10];
    int P[N][11];

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 10; ++j) {
            std::cin >> F[i][j];
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 11; ++j) {
            std::cin >> P[i][j];
        }
    }

    int max = INT32_MIN;
    for (int i = 1; i < (1 << 10); ++i) {
        int sum = 0;
        for (int j = 0; j < N; ++j) {
            int cnt = 0;
            for (int k = 0; k < 10; ++k) {
                if ((i >> k) & F[j][k]) {
                    cnt++;
                }
            }
            sum += P[j][cnt];
        }

        max = std::max(max, sum);
    }

    std::cout << max << std::endl;

    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    x = LI()
    for i in range(5):
        if x[i] == 0:
            print(i+1)
            return
    return

#Solve
if __name__ == "__main__":
    solve()


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

std::vector<int> A, B;

int main(void){
    int n; std::cin >> n;
    A.resize(n); for(int i = 0; i < n; ++i) std::cin >> A[i];
    B.resize(n); for(int i = 0; i < n; ++i) B[A[i] - 1] = i + 1;
  
    std::cout << B[0]; for(int i = 1; i < n; ++i) std::cout << ' ' << B[i];
    std::cout << '\n';
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

string str;

char conv(int i, int j) {
  int ord = (i-1) * 5 + (j-1);
  if (ord >= 0 && ord < 26) return 'a' + ord;
  if (ord == 26) return '.';
  if (ord == 27) return '?';
  if (ord == 28) return '!';
  if (ord == 29) return ' ';
  if (ord >= 30) return 'N';
}


string solve() {
  int n = str.size();
  if (n & 1) return "NA";
  string res = "";
  for (int i = 0; i < n; i += 2) {
    int a = str[i] - '0', b = str[i+1] - '0';
    //cout << a << ", " << b << endl;
    if (a < 1 || a > 6) return "NA";
    if (b < 1 || b > 5) return "NA";
    char c = conv(a, b);
    res += c;
  }
  return res; 
}

int main() {
  while (cin >> str) {
    cout << solve() << endl;
  }
}


Measured memory_bytes: 1196
n = int(input())
S = [input() for _ in range(n)]
alp = [[0]*n for _ in range(26)]
OFS = ord('a') # 97

for i, s in enumerate(S):
  for x in s:
    alp[ord(x)-OFS][i] += 1
    

ans = ''
for i, a in enumerate(alp):
  ans += chr(i+OFS)*min(a)

print(ans)

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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(int i=x;i<n;i+=y)
#define FF(i,x,n,y) for(int i=x;i>=n;i-=y)
#define fa(x,y) for(auto x:y)

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;

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

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    vii v(n);
    f(n) cin>>v[i].ss>>v[i].ff;
    sort(all(v));
    int cur=0;
    f(n){
        auto x=v[i];
        cur=cur+x.ss;
        if(cur>x.ff){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}



Measured memory_bytes: 4716
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const int INF=1000000;
ll x[100001],y[100001];
ll x2[100001]={};
ll y2[100001]={};
int main() {
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;++i){
		cin>>x[i];
		x2[i]=x2[i-1]+x[i];
	}
	for(int i=1;i<=m;++i){
		cin>>y[i];
		y2[i]=y2[i-1]+y[i];
	}
	ll r=0;
	ll x3=0,y3=0;
	for(int i=1;i<n;++i)x3=(x3+x2[n]-x2[i]-x[i]*(n-i))%1000000007;
	for(int i=1;i<m;++i)y3=(y3+y2[m]-y2[i]-y[i]*(m-i))%1000000007;
	cout<<(x3*y3)%1000000007<<endl;
	return 0;
}


Measured memory_bytes: 3328
L = list(input().split(' '))
s = []

for l in L:
    if l == '+':
        a = s.pop()
        b = s.pop()
        s.append(a + b)
    elif l == '-':
        a = s.pop()
        b = s.pop()
        s.append(b - a)
    elif l == '*':
        a = s.pop()
        b = s.pop()
        s.append(a * b)
    else:
        s.append(int(l))
print(s[0])



Measured memory_bytes: 5600
// D.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#include <iostream>
#include<string>
using namespace std;

int main()
{
    int n, k, r, s, p;
    string t;

    cin >> n >> k;
    cin >> r >> s >> p;

    cin >> t;
    int sum = 0;
    int flag[100000];
    for (int i = 0; i < n; i++) {
        flag[i] = 0;
    }
    for (int i = 0; i < t.size(); i++) {
        if (i < k) {
            if (t[i] == 'r') {
                sum += p;
                flag[i] = 1;
            }
            else if (t[i] == 's') {
                sum += r;
                flag[i] = 1;
            }
            else {
                sum += s;
                flag[i] = 1;
            }
        }
        else {
            if (t[i] == t[i - k] && flag[i - k] == 1) {
                continue;
            }
            else {
                if (t[i] == 'r') {
                    sum += p;
                    flag[i] = 1;
                }
                else if (t[i] == 's') {
                    sum += r;
                    flag[i] = 1;
                }
                else {
                    sum += s;
                    flag[i] = 1;
                }
            }
        }
    }
    cout << sum << endl;
    return 0;
}



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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define inf (long long int) 1e18
#define eps 0.000001
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define mod 1000000007
#define MAXN 15000001
ll spf[MAXN]; 
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);
void sieve();
ll ceil(ll a, ll b);
sl getFactorization(ll x);
void getZarr(string str, ll Z[]);


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/

    string s;
    cin>>s;
    ll ans=INT_MAX;
    loop(i,0,s.length()-2){
        string s2(s,i,3);
        ll x=0;
        //cout<<s2<<"Lo "<<endl;
        x=(s2[0]-'0')*100+(s2[1]-'0')*10+(s2[2]-'0');
        //cout<<x<<endl;
        ans=min(ans,abs(753-x));
    }
    cout<<ans<<endl;

}

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

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

void sieve() { 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

sl getFactorization(ll x) 
{ 
    sl ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

ll ceil(ll a,ll b){
    return a/b+(a%b!=0);
}

void getZarr(string str, ll Z[]){
    ll n = str.length();
    ll L, R, k;
    L = R = 0;
    for (ll i = 1; i < n; ++i){
        if (i > R){
            L = R = i;
            while (R<n && str[R-L] == str[R])
                R++;
            Z[i] = R-L;
            R--;
        } else {
            k = i-L;
            if (Z[k] < R-i+1)
                Z[i] = Z[k];
            else {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		double res=inf;
		for(int i=0;i<=n;i++) res=min(res,fabs(sqrt(i*i+(n-i)*(n-i))-m));
		cout<<syosu(9)<<res<<endl;
	}
}


Measured memory_bytes: 3204
#include<stdio.h>

int main() {
    int n,i,u,k,v,j;
    scanf("%d",&n);
    int g[n][n];
    for(i=0;i<n;i++){
	for(j=0;j<n;j++){
	    g[i][j]=0;
	}
    }
    for(i=0;i<n;i++){
	scanf("%d %d",&u, &k);
	for(j=0;j<k;j++){
	    scanf("%d",&v);
	    g[u-1][v-1]=1;
	}
    }
    for(i=0;i<n;i++){
	for(j=0;j<n;j++){
	    if (j) printf(" ");
	    printf("%d",g[i][j]);
	    if(j==n-1)printf("\n");
	}
    }
    return 0;
}

Measured memory_bytes: 636
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pop_b pop_back
#define pf push_front
#define pop_f pop_front
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double ld; 
typedef vector<int> vi;
typedef vector<set<ll>> vset;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef deque<ll> dql;
typedef deque<int> dqi;
typedef unsigned long long ull;
typedef tuple<int,int,int> State;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << ", ";
	err(++it, args...);
	cout<<"\n";
}

#define vmax(type)   std::numeric_limits<type>::max()
#define vmin(type)   std::numeric_limits<type>::min()
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;
#define resize_vec(a) a.resize(unique(a.begin(), a.end()) - a.begin());
#define ms(dp, x) memset(dp, x, sf(dp))
#define endl '\n'

ll powm(ll a, ll b, ll mod) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const ll mod = 1e9 + 7;
const ll N = 1000005;
const ll inf = 1e9;

void solve()
{
	int n;
	cin>>n;
	int ans = 0, cnt = 0;
	rep2(i, 1, n){
		rep2(j, i, n){
			if(i * j < n){
				ans++;
				if(i == j)
					cnt++;
			}else
				break;
		}
	}
	cout<<ans*2-cnt<<endl;
}

// #define _DEBUG 
// #define testCases
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(15);
	
	int tc = 1;
#ifdef testCases
	cin>>tc;
#endif
	while(tc--)
	{
#ifdef _DEBUG
	int tt = clock();
#endif
		solve();
		
#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif
	}
	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=1005;
const ll INF=1LL<<60;

ll dp[MAX][MAX*20];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<pair<ll,pair<ll,ll>>> S(N);
    for(int i=0;i<N;i++){
        ll a,b,c;cin>>a>>b>>c;
        S[i]=mp(a+b,mp(a,c));
    }
    sort(all(S));
    
    for(int i=0;i<N;i++){
        for(int j=0;j<=20000;j++){
            chmax(dp[i+1][j],dp[i][j]);
            if(j<=S[i].fi-S[i].se.fi){
                chmax(dp[i+1][j+S[i].se.fi],dp[i][j]+S[i].se.se);
            }
        }
        for(int j=1;j<=20000;j++) chmax(dp[i+1][j],dp[i+1][j-1]);
    }
    
    cout<<dp[N][20000]<<endl;
}



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

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]
#define MAXF 510000

ll fac[MAXF], finv[MAXF], inv[MAXF];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAXF; 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;
}

int main(){
  ll n, K;
  ll a, b;
  ll sum=0;

  scanf("%lld%lld", &n, &K) ;

  COMinit();

  for (ll i = K; i <= n+1; i++)
  {
      a = i*(i-1)/2;
      b = i*(2*n-i+1) /2;
      sum = (sum + (b-a+1)) % MOD;
  }

  printf("%lld", sum);
  
  

  return 0;
}

Measured memory_bytes: 13692
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Set<Integer> hs = new HashSet<Integer>();
		for(int i = 0; i < n; i++){
			hs.add(scan.nextInt());
		}
		System.out.println(hs.size());
	}
}

Measured memory_bytes: 23764
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	char s[n];
	for(int i = 0; i < n; i++)
	{
		cin >> s[i];
	}
	
	for(int i = 0; i < n; i++)
	{
		if(s[i] == 'Y')
		{
			cout << "Four" << endl;
			return 0;
		}
	}
	
	cout << "Three" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<P, int>> PY(M);
  for (int i = 0; i < M; i++) {
    int p, y;
    cin >> p >> y;
    PY[i] = {{p, y}, i};
  }
  sort(begin(PY), end(PY));

  vector<pair<int, P>> ans(M);
  int cnt = 0;
  for (int i = 0; i < M; i++) {
    if (i > 0 && PY[i - 1].first.first != PY[i].first.first) {
      cnt = 0;
    }
    ans[i] = {PY[i].second, {PY[i].first.first, ++cnt}};
  }
  sort(begin(ans), end(ans));
  for (int i = 0; i < M; i++) {
    cout << setfill('0') << setw(6) << right << ans[i].second.first;
    cout << setfill('0') << setw(6) << right << ans[i].second.second;
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int minic=100000,maxf=-1;
	char a[1000];
	cin>>a;
	for(int i=0;i<strlen(a);i++)
	if(a[i]=='C'&&(i<minic))minic=i;
	for(int i=0;i<strlen(a);i++)
	if(a[i]=='F'&&i>maxf)maxf=i;
	if(minic<=999&&maxf>=0&&minic<maxf)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

long long n, m, a, b, d[200001];
vector<long long> adj[200001];
queue<long long> q;
int main(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	q.push(1);
	memset(d, -1, sizeof(d));
	d[1] = 0;
	while(!q.empty()){
		long long f = q.front(); q.pop();
		for(int i = 0; i < adj[f].size(); i++){
			if(d[adj[f][i]] == -1 || d[adj[f][i]] > d[f]+1){
				d[adj[f][i]] = d[f]+1;
				q.push(adj[f][i]);
			}
		}	
	}
	cout << (d[n] == 2 ? "POSSIBLE" : "IMPOSSIBLE");
}

Measured memory_bytes: 15208
#include<stdio.h>
int min(int a,int b){return a<b?a:b;}
int main(){
	while(1){
		int n;
		int i,j,k;
		scanf("%d",&n);
		if(n==0)return 0;
		int ans=1000000;
		int res1,res2;
		int cost1,cost2,cost3;
		for(i=0;i<(int)n/200+1;i++){
			cost1=0;
			cost2=0;
			cost3=0;
			res1=n-i*200;
			cost1=i*380-(int)(i/5)*380;
			for(j=0;j<(int)res1/300+1;j++){
				res2=res1-j*300;
				cost2=cost1+j*550-(int)(j/4)*330;
				for(k=(int)res2/500;k<(int)res2/500+1;k++){
					if(res2-k*500>0)break;
					else{
						cost3=cost2+k*850-(int)(k/3)*306;
						ans=min(ans,cost3);
					}
				}
			}
		}
		printf("%d\n",ans);
	}
}
				

Measured memory_bytes: 1028
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    string s;
    cin >> s;
    n = s.size();

    if(s[n-1] == '1') {
        cout << -1 << endl;
    } else {
        int x = 0;
        rep(i, n/2) {
            if(s[i] != s[n-2-i] or s[0] == '0') {
                cout << -1 << endl;
                return 0;
            }
        }
        rep(i, n/2) {
            if(i) {
                if(s[i] == '1') {
                    for(;x < i; ++x) {
                        cout << x+1 << ' ' << i+1 << endl;
                        cout << n-x << ' ' << n-i << endl;
                    }
                }
            }
        }
        for(;x < n/2; ++x) {
            cout << n-x << ' ' << n-n/2 << endl;
            if(x == n/2-1 and n%2 == 0) continue;
            cout << x+1 << ' ' << n-n/2 << endl;
        }

    }
}


Measured memory_bytes: 1664
import math
import fractions
from collections import deque
import itertools
import pprint
from heapq import *
N,M,S=map(int,input().split())
costtree={}                                                     #cost情報を格納costtree[頂点][coin数]
path=[[] for _ in range(N)]                                     #道情報
pathtime=[list(map(int,input().split())) for _ in range(M)]     #u,v,a,b(path情報と要するcoin,time)
cointime=[list(map(int,input().split())) for _ in range(N)]     #c,d(頂点ごとの一斉交換枚数,時間)
needtime=[[float("inf") for _ in range(N)] for _ in range(N)]   #path間の移動に必要な時間
needcoin=[[float("inf") for _ in range(N)] for _ in range(N)]   #path間の移動に必要なcoin数
change=[]
for i in range(N):
    costtree[i]={}
    for j in range(2501):
        costtree[i][j]=float("inf")
#print(costtree[0])
for i in pathtime:
    u,v,a,b=i
    needcoin[u-1][v-1]=a
    needcoin[v - 1][u - 1] = a
    needtime[u-1][v-1]=b
    needtime[v - 1][u - 1] = b
    path[u-1].append(v-1)
    path[v-1].append(u-1)
for i in cointime:
    c,d=i
    change.append([c,d])                                        #各点の[一度に両替するcoin数,時間]を格納
#print(needcoin,needtime,change,path)
costtree[0][min(S,2500)]=0                                      #costtreeは頂点0、min(S,2500)枚のコイン所持で0コストスタート
q=[(0,0,min(S,2500))]                                           #[cost,頂点,coin数]の組
heapify(q)
#print("ok")
#input()
value=0
nextcoin=0
while len(q)>0:
    cost,u,coin=heappop(q)                                      #[現時点の最小コスト,頂点,所持コイン数]をパージ
    if costtree[u][coin]<cost: continue                         #popしたコストが現存するコストを超えるなら無視
    if coin>0:                                                  #coinが0枚以上で
        if costtree[u][coin-1]>cost:                            #(cost0で)1枚捨てた時のコストが現存コストを下回るなら
            costtree[u][coin-1]=cost                            #捨てるようcost更新
            heappush(q,[cost,u,coin-1])                         #捨てた状態をqにpush
    nextcoin=min(coin+change[u][0],2500)                        #続いて、ここでコイン交換することを考え、交換した後の枚数を求める(2500枚を超えるなら明らかに2500枚で切って問題ないことに注意)
    value=costtree[u][nextcoin]                                 #交換あとの現存コスト
    if value>cost+change[u][1]:                                 #現存コストが、ここで交換する時より高いなら
        costtree[u][nextcoin]=cost+change[u][1]                 #ここで交換するようcostを更新し
        heappush(q,[cost+change[u][1],u,nextcoin])              #交換あとの状態をqにpush
    for j in path[u]:                                           #uから出るpathでたどりつく頂点jを考えます
        nextcoin=coin-needcoin[u][j]                            #jにたどり着いたときのコイン数
        if nextcoin>=0:                                         #コインが残っているなら
            value=costtree[j][nextcoin]                         #行き先の現存costを算出
            if value > cost + needtime[u][j]:                   #現存コストが、ここへ移動する時より高いなら
                costtree[j][nextcoin]=cost+needtime[u][j]       #ここで移動するようcostを更新し
                heappush(q,[cost+needtime[u][j],j,nextcoin])    #移動あとの状態をqにpush
for i in range(1,N):
    print(costtree[i][0])                                       #最小コストは下に流れるようになっているので、それぞれの頂点でcoin=0の時のcostが答え




Measured memory_bytes: 102516
n = int(input())
flag = 0
for i in range(9,0,-1):
  if n % i == 0:
    if n / i > 9:
      print("No")
      flag = 1
      break
    elif 0 < n / i:
      flag = 1
      print("Yes")
      break
if flag == 0:
  print("No")

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public void Run()
        {
            N = Input.ReadInt();

            if (N == 10 || N == 100 || N == 1000 || N == 10000 || N == 100000)
            {
                Console.WriteLine(10);
            }
            else
            {
                int ret = 0;
                while (N > 0)
                {
                    ret += N % 10;
                    N /= 10;
                }
                Console.WriteLine(ret);
            }
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>

using namespace std;

int main(){

   string s, t;
   int s_l, t_l;
   int ans = 10000;

   cin >> s >> t;

   s_l = s.length();
   t_l = t.length();

   for(int i = 0; i <= s_l - t_l; i++){
      int diff = 0;
      for(int j = 0; j < t_l; j++){
         if(s[i + j] != t[j]){
            diff++;
         }
      }
      if(diff < ans){
         ans = diff;
      }
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n >> m;
  if (n <= m) {
    cout << "unsafe\n";
  } else {
    cout << "safe\n";
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




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

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    int a=0;
    a=min(n,m);
    if(n<m){
    a+=min(m,l);
    }else{
    a+=min(n,l);
    }
    cout << a <<endl;
}

Measured memory_bytes: 256
N= int(input())
a = [0]*110000
if N == 2:
  print(2)
else:
  for i in range(2,N):
    k = i
    j = 2
    while k<110000:
      a[k]+=1
      k = int((k/(j-1))*j)
      j+=1
  
  for i in range(N,110001):
    if a[i]>0:
      continue
    elif a[i]==0:
      print(i)
      break

Measured memory_bytes: 9864
h,w=map(int,input().split())
s=[]
ans=[['' for _ in range(w)] for _ in range(h)]
for i in range(h):
  s.append(list(input()))
for i in range(h):
  for j in range(w):
    if s[i][j]=="#":
      ans[i][j]="#"
    else:
      count=0
      for p in range(max(0,i-1),min(h-1,i+1)+1):
        for q in range(max(0,j-1),min(w-1,j+1)+1):
          if s[p][q]=="#":
            count+=1
      ans[i][j]=str(count)
for i in range(h):
  print("".join(ans[i]))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
   ll w,h,n,l=0,d=0,r=INT_MAX,u=INT_MAX;
   cin>>w>>h>>n;
   r=w,u=h;
   for(int i=1;i<=n;i++)
   {
    ll xi,yi,a;
    cin>>xi>>yi>>a;
    if(a==1)
    {
         l=max(l,xi);
    }
    else if(a==2)
    {
          r=min(r,xi);
    }
    else if(a==3)
    {
        d=max(d,yi);
    }
    else if(a==4)
    {
         u=min(u,yi);
    }
   }
   //cout<<(max(r-l,0ll)*max(u-d,0ll))<<endl;
   ll length=r-l;
   ll breadth=u-d;
   ll res=1ll*length*breadth;
   if(length<=0||breadth<=0)
    cout<<0<<endl;
  else
    cout<<res<<endl;
   //cout<<max(0ll,res)<<endl;
   
  /* cerr<<fcx<<" "<<fcy<<endl;
   cerr<<scx<<" "<<scy<<endl;
   ll length=scx-fcx;
   ll breadth=scy-fcy;
   ll res=1ll*length*breadth;
   cout<<max(0ll,res)<<endl;
  */

}
return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
    int b,t,mai,a;
    //input
    cin >> a >> b >> t;
    //do
    for(int i=0;i<t+1;i++){
        if(i%a==0&&i!=0)mai+=b;
    }
    cout << mai << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>;
void chmax(ll& a, ll b) { a = max(a, b); }

ll n;
ll dp[2003][2003];

signed main() {
    cin >> n;
    vl a(n);
    rep(i,n) cin>>a[i];
    vector<pll> b(n);
    rep(i,n) b.emplace_back(a[i], i);
    sort(b.rbegin(), b.rend());

    FOR(i, 0, n) {
        ll ai = b[i].first;
        ll pi = b[i].second;
        FOR(l, 0, i+1) {
            ll r = i - l;
            chmax(dp[i+1][l+1], dp[i][l] + ai * (pi-l));
            chmax(dp[i+1][l], dp[i][l] + ai * ((n-r-1)-pi));

        }
    }
    ll ans = 0;
    rep(i,n) ans = max(ans, dp[n][i]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 26380
#include <stdio.h>

int main(void) {
    int a, b, c, x;
    int ia, ib, ic, sum, match;
    int ret;

    ret = scanf("%d", &a);
    ret = scanf("%d", &b);
    ret = scanf("%d", &c);
    ret = scanf("%d", &x);
    
    match = 0;
    for(ia = 0; ia <= a; ia++) {
	    for(ib = 0; ib <= b; ib++) {
		    for(ic = 0; ic <= c; ic++) {
		    	sum = ia * 500 + ib * 100 + ic * 50;
		    	if(sum == x) {
		    		match++;
		    	}
		    }
	    }
    }
	
    printf("%d\n", match);
	
    return 0;
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> &str{
    input!{
        source = src,
        x: isize,
        y: isize,
    }

    for n in 0..x {
        let kame = 1 + n;
        let tsuru = x - kame;
        let ashi = kame * 4 + tsuru * 2;
        if ashi == y {
            return "Yes";
        }
    }

    for n in 0..x {
        let tsuru = 1 + n;
        let kame = x - tsuru;
        let ashi = kame * 4 + tsuru * 2;
        if ashi == y {
            return "Yes";
        }
    }

    return "No";
}


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

using namespace std;

typedef long long int ll;

const ll inf = 1e18;
const ll MAXN = 205;

vector < vector < ll > > adj(MAXN, vector < ll > ());

bool check_bipartite(){
  queue < ll > q;
  vector < bool > used(MAXN, false);
  vector < ll > cnt(MAXN, 0);
  q.push(1);
  used[1] = true;
  bool is_bipartite = true;
  while(!q.empty()){
    ll u = q.front(); q.pop();
    for(auto to : adj[u]){
      if(!used[to]){
        used[to] = true;
        cnt[to] = 1 ^ cnt[u];
        q.push(to);
      }else{
        is_bipartite &= cnt[to] != cnt[u];
      }
    }
  }

  return is_bipartite;
}

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

  int n;
  cin >> n;
  vector < vector < ll > > d(n + 1, vector < ll > (n + 1, inf));
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      char ch;
      cin >> ch;
      if(ch == '1'){
        d[i][j] = 1;;
        adj[i].push_back(j);
      }
      if(i == j) d[i][j] = 0;
    }
  }

  if(!check_bipartite()){
    cout << -1 << '\n';
    exit(0);
  }

  for(int k = 1; k <= n; k++){
    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= n; j++){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  ll mx = -inf;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      if(d[i][j] != inf) mx = max(mx, d[i][j]);
    }
  }

  cout << mx + 1 << '\n';
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){

    int w,h; //rectangle
    int x,y,r; //circle

    scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
    
    if(0 <= x-r && x + r <= w && 0 <= y-r && y + r <= h){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 2692