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

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}

int n, s;
int ans;
void solve(int num, int m, int sum)
{
  if(sum > s || m > 10) return;
  if(num == 0)
  {
    ans += (sum == s);
    return;
  }
  solve(num-1,m+1,sum+m);
  solve(num,m+1,sum);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (1)
  {
    scanf("%d %d",&n,&s);
    if(n==0 && s==0) break;
    ans = 0; solve(n,0,0);
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3228
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	string S;
	cin >> S;
	reverse(S.begin(), S.end());
	int num = S[0] - '0';
	long long int n1 = num, n2 = 10 - num;
	for(int i = 1; i < S.size(); i++){
		num = S[i] - '0';
		long long int n1_ = min(n1 + num, n2 + 1 + num);
		long long int n2_ = min(n1 + 10 - num, n2 + 9 - num);
		n1 = n1_;
		n2 = n2_;
	}
	cout << min(n1, n2 + 1) << endl;
	return 0;
}

Measured memory_bytes: 1540
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  int A = 0;
  int W = 0;
  int T = 0;
  int R = 0;
  
  for(int i = 0; i < N; i ++){
    if(vec.at(i) == "AC"){
      A++;  
    }
    else if(vec.at(i) == "WA"){
      W++;
    }
    else if(vec.at(i) == "TLE"){
      T++;
    }
    else if(vec.at(i) == "RE"){
      R++;
    }
  }
  
  cout << "AC x ";
  cout << A << endl;
  
  cout << "WA x ";
  cout << W << endl;
  
  cout << "TLE x ";
  cout << T << endl;
  
  cout << "RE x ";
  cout << R << endl;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
int n,a[100003],f,s;
int main(){
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
sort(a+1,a+1+n);
for(int i=1;i<=n;i++){
f++;
if(a[i]!=a[i+1]){
if(f<a[i]) s+=f;
if(f>a[i]) s+=f-a[i];
f=0;}
}
cout<<s;}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>

struct Point { double x, y; };

void kock(int n, Point p1, Point p2){
    if(n == 0) return;
    
    Point s, t, u;
    double th = M_PI * 60 / 180;
    
    s.x = (2 * p1.x + p2.x) / 3;
    s.y = (2 * p1.y + p2.y) / 3;
    t.x = (p1.x + 2 * p2.x) / 3;
    t.y = (p1.y + 2 * p2.y) / 3;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
    
    kock(n-1, p1, s);
    printf("%.8f %.8f\n", s.x, s.y);
    kock(n-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    kock(n-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    kock(n-1, t, p2);
}

int main(){
    int n;
    Point p1, p2;
    
    scanf("%d", &n);
    
    p1.x = 0;
    p1.y = 0;
    p2.x = 100;
    p2.y = 0;
    
    printf("%.8f %.8f\n", p1.x, p1.y);
    kock(n, p1, p2);
    printf("%.8f %.8f\n", p2.x, p2.y);
    
    return 0;
}


Measured memory_bytes: 2744
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    if(s[1]=='R'){
        cout<<"ABC"<<"\n";
    }
    else{
        cout<<"ARC"<<"\n";
    }
}


Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
typedef long long int ll;

int N;
vector<int> A;
vector<int> B;


int main()
{
  int i,j,k;

  cin >> N;

  A.resize(N);
  B.resize(N);

  for (i=1; i<N; i++) {
    cin >> A[i];
  }
  for (i=1; i<N; i++) {
    B[A[i]-1]++;
  }
  for (i=0; i<N; i++) {
    printf("%d\n", B[i]);
  }

  return 0;
}


Measured memory_bytes: 4780
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class BRollerCoaster {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k; cin >> n >> k;
      int ans = 0;
      rep(i, n) {
        int h; cin >> h;
        if (h >= k) {
          ans++;
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  BRollerCoaster solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
n,k=map(int, input().split())
h=list(map(int, input().split()))
dp=[float('inf')]*n
dp[0]=0
for i in range(n):
  for j in range(1,min(k+1,n-i)):
    dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
print(dp[n-1])

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

int main(){
  string a, b, ans = "EQUAL";
  cin >> a >> b;
  
  if (a.size() > b.size()) ans = "GREATER";
  else if (a.size() < b.size()) ans = "LESS";
  else {
    for (int i=0; i<a.size(); i++) {
      if (int(a[i]) > int(b[i])) {
        ans = "GREATER";
        break;
      }
      else if (int(a[i]) < int(b[i])) {
        ans = "LESS";
        break;
      }
    }
  }

  cout << ans << endl;  
    
  return 0;  
}

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

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

using namespace std;

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

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

void solve() {
  int n;
  cin >> n;
  vector<pair<string, int>> vp;
  rep(i, n) {
    string s;
    int x;
    cin >> s >> x;
    vp.emplace_back(s, x);
  }
  string s;
  cin >> s;
  bool sleep = false;
  int ans = 0;
  rep(i, n) {
    string t;
    int x;
    tie(t, x) = vp[i];
    if (sleep) ans += x;
    if (s == t) sleep = true;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque

H,W = map(int,input().split())
maze = [list(input()) for i in range(H)]
gy, gx = H-1, W-1
maze[0][0]=1

blackTiles = 0
for i in range(H):
  for j in range(W):
    if maze[i][j]=="#":
      blackTiles += 1
      
que = deque([[0,0]])
patterns = [[1,0],[-1,0],[0,1],[0,-1]]
flag = False
while que:
  now = que.popleft()
  nowY = now[0]
  nowX = now[1]
  nowStep = maze[nowY][nowX]
  if nowY == gy and nowX == gx:
    ret = nowStep
    flag = True
    break
  for pattern in patterns:
    nextY = nowY + pattern[0]
    nextX = nowX + pattern[1]
    nextStep = nowStep + 1
    if 0 <= nextY < H and 0<= nextX < W and maze[nextY][nextX]==".":
      maze[nextY][nextX] = nextStep
      que.append([nextY,nextX])
if flag:
  print(H*W-ret-blackTiles)
else:
  print(-1)


Measured memory_bytes: 3316
import java.util.Scanner;

class Main{

  static boolean solve(int[] a, int m, int i){
    if(m == 0)
      return true;
    if(i == a.length)
      return false;
    else
      return solve(a, m, i + 1) || solve(a, m - a[i], i + 1);
  }


  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++)
      a[i] = stdIn.nextInt();

    int q = stdIn.nextInt();
    int[] b = new int[q];
    for(int i = 0; i < q; i++)
      b[i] = stdIn.nextInt();

    for(int i = 0; i < q; i++){
      if(solve(a, b[i], 0))
        System.out.println("yes");
      else
        System.out.println("no");
    }
  }
}

Measured memory_bytes: 26884
#include <bits/stdc++.h>
#define fast_io                                                                \
    ios::sync_with_stdio(false);                                               \
    cin.tie(0)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf = 0x3f3f3f3f;
const int N = (int)1e3 + 5;
const int M = (int)1e5 + 5;
const int mod = (int)1e9 + 7;
const double esp = 1e-8;
int T;
//------------------------------
int main() {
    fast_io;
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j * i < n; ++j) {
            ++cnt;
        }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
# BIT使ってC問題ちゃんとやろうとしたけど1時間かけて無を生成したので諦める。ぷえwwwww
from random import randint
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split()))for _ in range(d)]
for i in range(d):s.append(s[i][:])
for i in range(d):s.append(s[i][:])
def xyz(start):
  ans=[0]*d
  score=0
  for i in range(start,start+d,26):
    dd=set()
    uu=set()
    h=[]
    for j in range(i,min(i+26,start+d)):
      for k in range(26):
        h.append([s[j][k],j,k])
    h.sort(reverse=1)
    if randint(0,4)==0:del h[0]
    for t,j,k in h:
      if j in dd or k in uu:continue
      score+=t
      ans[j%d]=k
      dd.add(j)
      uu.add(k)
  return [score,ans]
score,ans=xyz(0)
for i in range(1,d):
  ss,aa=xyz(i)
  if ss>score:
    score,ans=ss,aa
for i in ans:print(i+1)

Measured memory_bytes: 10032
#include <vector>
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
using namespace std;

// 累積演算 (0-indexed・prefix, suffix, 任意連続部分列)
// 任意連続部分列は逆演算があるときのみできる？

template <typename MonoidType>
struct Accumulation {
    int n;
    vector<MonoidType> pre, suf;
    MonoidType E;
    
    using MMtoM = function< MonoidType(MonoidType, MonoidType) >;
    MMtoM op, rop;

    void build(int m, vector<MonoidType> vec) {
        pre = suf = vector<MonoidType>(m+1, E);
        for(int i=0; i<m; i++) {
            pre[i+1] = op(pre[i], vec[i]);
        }
        for(int i=m-1; i>=0; i--) {
            suf[i] = op(suf[i+1], vec[i]);
        }
    }

    Accumulation() {}
    Accumulation(vector<MonoidType> val_array, MonoidType E_,
                 MMtoM op_, MMtoM rop_ = MMtoM()) :
        E(E_), op(op_), rop(rop_) {
        n = val_array.size();
        build(n, val_array);
    }

    // [0, k)
    inline MonoidType get_prefix(int k) { return 0 <= k and k <= n ? pre[k] : E; }
    // [k, n)
    inline MonoidType get_suffix(int k) { return 0 <= k and k <= n ? suf[k] : E; }
    // [l, r) (rop が定義されてるときのみ)
    inline MonoidType get_subseq(int l, int r) {
        return rop(get_prefix(r), get_prefix(l));
    }
};


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

// Verified on Apr 28, 2019 (prefix, suffix のみ)
// Judge: https://atcoder.jp/contests/abc125/tasks/abc125_c
void ABC125_C() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    
    Accumulation<int> acc(A, 0,
                          [](int a, int b) { return gcd(a, b); });

    int ans = 0;
    for(int i=0; i<N; i++) {
        int vl = acc.get_prefix(i), vr = acc.get_suffix(i+1);
        ans = max(ans, gcd(vl, vr));
    }
    cout << ans << endl;
}

// Verified on Apr 28, 2019 (subseq のみ)
// Judge: https://atcoder.jp/contests/abc122/tasks/abc122_c
void ABC122_C() {
    int N, Q; cin >> N >> Q;
    string s; cin >> s;

    vector<int> A(N);
    for(int i=1; i<N; i++) {
        A[i] = (s[i-1] == 'A' and s[i] == 'C');
    }

    Accumulation<int> acc(A, 0,
                          [](int a, int b) { return a + b; },
                          [](int a, int b) { return a - b; });

    for(int i=0; i<Q; i++) {
        int l, r; cin >> l >> r;
        cout << acc.get_subseq(l, r) << endl;
    }
}

int main() {
    // ABC125_C();
    ABC122_C();
    return 0;
}


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

int main() {
    int64_t n;
    cin >> n;
    vector<int64_t> cnt(n+1, 1);
    for(int64_t i = 2; i <= n; i++){
        for(int64_t j = 1; i * j <= n; j++){
            cnt[i * j]++;
        }
    }
    int64_t ans = 0;
    for(int64_t i = 1; i <= n; i++){
        ans += (i * cnt[i]);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> vec){ return (ll)vec.size(); }
ll sz(string s){ return (ll)s.size(); }

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

int main(){
    ll n,m,r;
    cin >> n >> m >> r;
    
    ll d[n][n] = {};
    rep(i,0,n) rep(j,0,n) if(i != j) d[i][j] = LINF;

    ll memo[r] = {};
    rep(i,0,r){
        cin >> memo[i];
        memo[i]--;
    }

    rep(i,0,m){
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    rep(k,0,n) rep(i,0,n) rep(j,0,n) d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    
    ll array[r] = {};
    rep(i,0,r) array[i] = i;

    ll ans = LINF;
    do{
        ll temp = 0;
        rep(i,1,r){
            temp += d[memo[array[i-1]]][memo[array[i]]];
        }
        ans = min(ans,temp);
    }while(next_permutation(array,array+r));
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	int n;
	cin >> n;
	vector<pair<int, int> > Red(n), Blue(n);
	for (int i = 0; i < n; i++) {
		cin >> Red[i].second >> Red[i].first;
	}
	for (int i = 0; i < n; i++) {
		cin >> Blue[i].first >> Blue[i].second;
	}
	sort(Red.begin(), Red.end(), greater<pair<int, int> >());
	sort(Blue.begin(), Blue.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (Red[j].second < Blue[i].first && Red[j].first < Blue[i].second) {
				ans++;
				Red[j].first = INF, Red[j].second = INF;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, K;
  cin >> N >> K;
  ll common = 0;
  ll m = -1;
  REP(i, N) {
    ll a;
    cin >> a;
    common = GCD(common, a);
    m = max(m, a);
  }
  if (K % common == 0 && K <= m)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
  
  static int INFTY = 999999;
  static int WHITE = 0;
  static int GRAY = 1;
  static int BLACK = 2;
  int n;
  int M[100][100];
  void dijkstra(){
    int minv;
    int d[100],color[100];
    for(int i = 0; i < n;i++){
      d[i] = INFTY;
      color[i] = WHITE;
    }
    d[0] = 0;
    color[0] = GRAY;
    while(1){
      minv = INFTY;
      int u = -1;
      for(int i = 0;i < n;i++){
if(minv > d[i] && color[i] != BLACK){
 u = i;
 minv = d[i];
}
}
      if(u == -1)break;
      color[u] = BLACK;
      for(int v = 0;v < n;v++){
if(color[v] != BLACK && M[u][v] != INFTY){
 if(d[v] > d[u] + M[u][v]){
   d[v] = d[u] + M[u][v];
   color[v] = GRAY;
   }
}
      }
    }

    for(int i = 0;i < n;i++){
        printf("%d %d\n",i,(d[i] == INFTY? -1 : d[i]));
        }
  }

  int main(){
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
      for(int j = 0;j < n;j++){
M[i][j] = INFTY;
      }
    }

    int k,c,u,v;
    for(int i = 0;i < n;i++){
      scanf("%d%d",&u,&k);
      for(int j = 0;j < k;j++){
          scanf("%d%d",&v,&c);
          M[u][v] = c;
      }
    }
    dijkstra();
    return 0;
}







Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int sum;
	int i;
	cin>>n;
	sum=100000;
	for(i=1;i<=n;i++){
		sum*=1.05;
		if(sum%1000)	sum=sum-sum%1000+1000;
	}
	cout<<sum<<endl;
	return 0;
	
}


Measured memory_bytes: 3080
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> a;
  for (int u = 0; u < n; u++) {
    string s;
    cin >> s;
    long long x = 0;
    int it = -1;
    for (int i = 0; i < (int) s.size(); i++) {
      if (s[i] == '.') {
        it = i;
        break;
      }
      x = x * 10 + (s[i] - '0');
    }
    if (it == -1) {
      for (int i = 0; i < 9; i++) x *= 10;
    } else {
      int c = 0;
      for (int i = it + 1; i < (int) s.size(); i++) {
        x = x * 10 + (s[i] - '0');
        c++;
      }
      for (;c < 9; c++) {
        x *= 10;
      }
    }
    cerr << x << endl;
    int five = 0;
    while (x % 5 == 0) {
      x /= 5;
      five++;
    }
    int two = 0;
    while (x % 2 == 0) {
      x /= 2;
      two++;
    }
    a.emplace_back(min(20, two), min(20, five));
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  vector<vector<int>> need(n);
  for (int i = 0; i < n; i++) {
    int two_need = 18 - a[i].first;
    int five_need = 18 - a[i].second;
    if (two_need <= a[i].first && five_need <= a[i].second) ans--;
    int idx = lower_bound(a.begin(), a.end(), make_pair(two_need, 0)) - a.begin();
    if (idx < n) need[idx].push_back(five_need);
  }
  vector<int> cnt(20);
  for (int i = n - 1; i >= 0; i--) {
    cnt[a[i].second]++;
    for (auto& five : need[i]) {
      for (int j = five; j < 20; j++) ans += cnt[j];
    }
  }
  cout << ans / 2 << endl;
  return 0;
}

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

int main() {
 int a , b , c;
 cin >> a >> b >> c;
 if(a == 7 && b == 5 && c == 5)cout << "YES" << endl;
 else if(a == 5 && b == 5 && c == 7)cout << "YES" << endl;
 else if(a == 5 && b == 7 && c == 5)cout << "YES" << endl;
 else cout << "NO" << endl;
 }


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
using ll = long long;
int a[100005], b[100005];
int main()
{
	// freopen("keyence2019-C.in", "r", stdin);
	int n, ans = 0;
	scanf("%d", &n);
	std::multiset<int> se;
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", a + i);
		sum += a[i];
	}
	for (int i = 0; i < n; i++)
	{
		scanf("%d", b + i);
		sum -= b[i];
		if (a[i] >= b[i])
			se.insert(a[i] - b[i]);
	}
	if (sum < 0)
	{
		puts("-1");
		return 0;
	}
	while (!se.empty())
	{
		int x = *se.begin();
		se.erase(se.begin());
		if (x > sum)
			break;
		sum -= x;
		ans++;
	}
	printf("%d\n", n - ans);
	return 0;
}


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

A = list(map(int, input().split()))

B = [0] + A + [0]
S = [0]*(N+2) 
for i in range(1, N+2):
    S[i] = S[i-1] + abs(B[i] - B[i-1])

max_s = S[-1]
for i in range(1, N+1):
    ans = 0
    ans += S[i-1]
    ans += abs(B[i-1]-B[i+1])
    ans += max_s - S[i+1]
    print(ans)


Measured memory_bytes: 20576
#include <iostream>
#include <algorithm>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <cmath>

using namespace std;

#define rip(i,n,s) for (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

struct UnionFind{
    int size;
    vector<int> par;
    vector<int> rank;
    UnionFind(int x){
        size=x;
        par=vector<int> (x);
        rank=vector<int> (x,1);
        for (int i=0;i<x;i++){
            par[i]=i;
        }
    }
    int root(int x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=root(par[x]);
        }
    }
    void unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y){
            return;
        }
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            par[y]=x;
        }
        if(rank[x]==rank[y]){
            rank[x]++;
        }
    }
    bool check(int x,int y){
        return root(x)==root(y);
    }
    void initialize(){
        for (int i=0;i<size;i++){
            par[i]=i;
        }
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    int a,b;
    rip(i,m,0){
        cin >> a >> b;
        uf.unite(a,b);
    }
    int q;
    cin >> q;
    vector<bool> ans(q);
    rip(i,q,0){
        cin >> a >> b;
        ans[i]=uf.check(a,b);
    }
    rip(i,q,0){
        if(ans[i]){
            printf("yes\n");
        }
        else{
            printf("no\n");
        }
    }
}


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

using namespace std;

void solve()
{
	string password;
	cin >> password;
	bool flagLength = false;
	bool flagNumber = false;
	bool flagCapital = false;
	bool flagSmall = false;
	if (password.size() >= 6)
	{
		flagLength = true;
	}
	for (int i = 0; i < password.size(); ++i)
	{
		if ('0' <= password[i] && password[i] <= '9')
		{
			flagNumber = true;
		}
		else if ('A' <= password[i] && password[i] <= 'Z')
		{
			flagCapital = true;
		}
		else if ('a' <= password[i] && password[i] <= 'z')
		{
			flagSmall = true;
		}
	}
	if (flagLength && flagNumber && flagCapital && flagSmall)
	{
		cout << "VALID" << endl;
	}
	else
	{
		cout << "INVALID" << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1176
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	long long a, b, x;
	cin >> a >> b >> x;
	if (a %x != 0)
		cout << b / x - a / x << endl;
	else
		cout << b / x - a / x + 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  
  string n;
  
  cin >> n;
  
  if(n[0]==n[1] && n[1]==n[2] ||
     n[1]==n[2] && n[2]==n[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    X = int(input())
    luck = (X // 500) * 1000 + (X % 500) // 5 * 5
    print(luck)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
import sys
sys.setrecursionlimit(1000000)
n, q = map(int, input().split())
parent = [i for i in range(n)]
def get_par(x):
  if x == parent[x]:return x
  parent[x] = get_par(parent[x])
  return parent[x]

for _ in range(q):
  com, x, y = map(int, input().split())
  px, py = get_par(x), get_par(y)
  if com == 0:
    parent[px] = py
  else:
    print(int(px == py))



Measured memory_bytes: 13108
def main():
    n = int(input())
    h = list(map(int, input().split()))
    # 増加してるマスのあたりをつけてあたりとあたりの距離で勝負する
    check_point = [0]
    if len(h) == 1:
        return 0
    for i in range(len(h)):
        if i == 0:
            continue
        if h[i - 1] < h[i]:
            check_point.append(i)
    if len(check_point) == 1:
        return n-1
    diffs = list()
    if check_point[-1] != n - 1:
        check_point.append(n - 1)
    for i in range(len(check_point)):
        if i == 0:
            continue
        if check_point[i] == n - 1 and h[n - 1] <= h[n - 2]:
            ans = check_point[i] - check_point[i - 1]
        else:
            ans = check_point[i] - 1 - check_point[i - 1]
        diffs.append(ans)
    return max(diffs)

# 0 ~ ci-1 間、 c1  ~ c2-1 間、 c2 ~ end間の距離のうちの最大値を求めてみる

answer = main()
print(answer)


Measured memory_bytes: 63984
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		int a,b,sum,digits;
		int i=1;
		String str;
		String num[]=new String[2];
		BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
		while(i<=200){
			if((str=in.readLine())==null)
				break;
			digits=1;
			num=str.split(" ",0);
			a=Integer.parseInt(num[0]);
			b=Integer.parseInt(num[1]);
			sum=a+b;
			while((sum=sum/10)!=0)
				digits++;
			System.out.printf(digits+"\n");
			i++;
		}
	}

}

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

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
// const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<vector<int>> vvi;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define umap unordered_map


int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; int k; cin >> n >> k;
	vll A = vll();
	vll dp = vll(n, LLINF);
	rep(i, n){
		ll x; cin >> x;
		A.pb(x);
	}
	dp[0] = 0;
	for(int i = 1; i < n; i++){
		for(int j = max(0, i - k); j < i; j++){
			dp[i] = min(dp[i], dp[j] + abs(A[j]-A[i]));
		}
	}
	cout << dp[isize(dp)-1];	
}

Measured memory_bytes: 5020
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int x;
  cin>>x;
  cout<<1-x<<endl;

  return 0;
}


Measured memory_bytes: 3668
///----------------------------------
/// 樹木にとって最も大切なものは何かと問うたら、
/// それは果実だと誰もが答えるだろう。
/// しかし実際には種なのだ。
/// 
/// - ニーチェ -
///----------------------------------
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
static const lint MOD = (lint)1e9+7;

int N;
vector<double> v;

int main()
{
    cin >> N;
    v.resize(N);
    rep (i, N) { cin >> v[i]; }

    sort(ALL(v));

    double ans = (v[0] + v[1]) / 2.0;

    for (int i = 2; i < N; ++i)
    {
        ans = (ans + v[i]) / 2.0;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
int a,b,c=0;
cin>>a;
b=a%1000%100;
c=(a-b)/100;
if(0<b&&b<13){
if(0<c&&c<13){
cout<<"AMBIGUOUS"<<endl;
}else{cout<<"YYMM"<<endl;}
}else{
  if(0<c&&c<13){
    cout<<"MMYY"<<endl;}else{
cout<<"NA"<<endl;}
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;
    
    bool flg = false;
    bool c = false;

    for(int i=0; i<s.size(); i++){
        if(c == false && s[i] == 'C') c = true;
        else if(c == true && s[i] == 'F') flg = true;
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
} 

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

int main() {
  int N, A, B, C;
  cin >> N;
  A = ( N / 10 ) % 100 ;
  B = N / 100;
  C = N % 100;

  if ( A == B || A == C ){
      cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

static int cnt=0;

int makeg(int n,int *G)//gを作成 制約条件を満たすようにn以下の平方根とした
{
	int x;
	int i;
	x=sqrt(n);
	if(x>100) x=100;
	for(i=x;i>0;i--){
		G[x-i]=i*i;
	}
	
	return x;
}


void insertionsort(int *a,int n,int g)
{
	int i,j,v=0;
	for(i=g;i<n;i++){//gずつ離れた全ての組をソートする
		v=a[i];
		j=i-g;
		while(j>=0&&a[j]>v){
			a[j+g]=a[j];//組の中で小さいものを左に移動する
			j=j-g;//gずつ左にずらす
			cnt++;
		}
		a[j+g]=v;//大きいものを右側に移動
	}
}

void shellsort(int *a,int n)
{
	int m=3,i;
	int *G;
	
	G=(int*)malloc(sizeof(int)*n);
	m=makeg(n,G);
	printf("%d\n",m);
	for(i=0;i<m;i++){
		if(i!=0) printf(" ");
		printf("%d",G[i]);	
		insertionsort(a,n,G[i]);
	}
	printf("\n");
	
	free(G);
}

int main(void)
{
	int n,*a,i;
	
	scanf("%d",&n);
	a=(int*)malloc(sizeof(int)*n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	shellsort(a,n);

	printf("%d\n",cnt);
	for(i=0;i<n;i++){
		printf("%d\n",a[i]);
	}
	printf("\n");
	free(a);
	return 0;
}


Measured memory_bytes: 5568
import math
n = int(input())
val = n
vals = []
for i in range(1, math.ceil(val**0.5) + 1):
    if val % i == 0:
        vals.append(i)
        
ans = float('inf')
for v in vals:
    ans = min(ans, max(len(str(v)), len(str(n // v))))
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define in1(n) cin>>n;
#define in2(n, k) cin>>n>>k;
#define in3(n, k, s) cin>>n>>k>>s;
#define scn(t) scanf("%d", &t)
#define scnld(t) scanf("%ld", &t)
#define scnlld(t) scanf("%lld", &t)
#define scnc(t) scanf("%c", &t)
#define scns(t) scanf("%s", t)
#define scnf(t) scanf("%f", &t)
#define scnlf(t) scanf("%lf", &t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define nloop(i, j, k, in) for (int i = j; i < k; i += in)
#define rloop(i, j, k, in) for (int i = j; i >= k; i -= in)
#define rep(i, j) nloop(i, 0, j, 1)
#define rrep(i, j) rloop(i, j, 0, 1)
#define inar(n, a) \
    rep(i, n)\
        cin>>a[i];
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)\
{\
return (a.second < b.second);\
}
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fast  \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

int main()
{
    fast
    int n;
    cin>>n;
    VI v(n);
    inar(n, v)
    int64 sum = 0;
    rep(i, n-1){
        if(v[i] > v[i+1]) sum += v[i]-v[i+1], v[i+1] = v[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3964
#include <stdio.h>

//#define DEBUG

#define LEN 10
int paper[LEN][LEN];

void init(void)
{
    int i,j;
    for(i=0;i<LEN;i++){
        for(j=0;j<LEN;j++){
            paper[i][j]=0;
        }
    }
}

//increse a certain point
void set(int x,int y)
{
    if(x<0 || y<0 || x>=LEN || y>=LEN){ return; } 
    paper[x][y]++;
}

//drop a ink
void drop_1(int x,int y)
{
    set(x,y);
    set(x+1,y);
    set(x-1,y);
    set(x,y+1);
    set(x,y-1);
}
void drop_2(int x,int y)
{
    drop_1(x,y);
    set(x+1,y+1);
    set(x+1,y-1);
    set(x-1,y+1);
    set(x-1,y-1);
}
void drop_3(int x,int y)
{
    drop_2(x,y);
    set(x+2,y);
    set(x-2,y);
    set(x,y+2);
    set(x,y-2);
}

void update(int x,int y,int size)
{
    if(size==1){ drop_1(x,y); }
    else if(size==2){ drop_2(x,y); }
    else if(size==3){ drop_3(x,y); }
}

void result(void)
{
    int cnt_no_ink=0,max_ink=0;
    int i,j;
    for(i=0;i<LEN;i++){
        for(j=0;j<LEN;j++){
            if(paper[i][j]==0){
                cnt_no_ink++;
            }
            if(paper[i][j]>max_ink){
                max_ink=paper[i][j];
            }
        }
    }
    printf("%d\n%d\n",cnt_no_ink,max_ink);
}



int main(void)
{
    FILE* fp;
#ifdef DEBUG
    fp=fopen("input.txt","r");
#else
    fp=stdin;
#endif
    init(); //init paper
    while(feof(fp)==0){
        int x,y,size;
        fscanf(fp,"%d,%d,%d\n",&x,&y,&size);
        update(x,y,size);
    }
    result(); //print result
    return 0;
}

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

int main() {
    //input
    int k;
    string s;
    cin >> k >> s;

    int i = 0;
    int m = 0;
    for(char c : s){
        if(c == 'I'){
            m = max(m,++i);
        }else{
            i--;
        }
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.AbstractMap;
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         long N=gl();
         long K=gl();
         String S=gs();

         int s=0;
         for(int i=0; i<N;i++) {
        	 char c=S.charAt(i);
        	 if(c=='L' && i!=0 && S.charAt(i-1)=='L') {
        		 s++;
        	 } else if(c=='R' && i!=N-1 && S.charAt(i+1)=='R') {
        		 s++;
        	 }
         }


         System.out.println(Math.min(N-1, s+2*K));
     }

     public static class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> implements Comparable<Pair<K, V>> {
    		/** serialVersionUID. */
    	    private static final long serialVersionUID = 6411527075103472113L;

    	    public Pair(final K key, final V value) {
    	        super(key, value);
    	    }

    		@Override
    		public int compareTo(Pair<K, V> o) {

    			Comparable key = (Comparable)this.getKey();
    			Comparable key2 = (Comparable)o.getKey();

    			return key.compareTo(key2);
    		}

    	}

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

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

string s,t;
int hasil=0;

int main() {
    cin>>s;
    cin>>t;
    for(int i=0; i<3; i++){
       if (s[i]==t[i]) hasil++;
    }
    cout<<hasil<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char mp[64][64];
int h,w;
int dy[]={-1,-1,0,1,1,1,0,-1};
int dx[]={0,1,1,1,0,-1,-1,-1};
int func(int y,int x){
  int rec=0;
  for(int i=0;i<8;i++){
    int ny=y+dy[i];
    int nx=x+dx[i];
    if(ny>=0&&ny<h&&nx>=0&&nx<w&&mp[ny][nx]=='#')
      rec++;
  }
  return rec;
}
int main(){
  cin >> h >> w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> mp[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(mp[i][j]=='.'){
        int temp=func(i,j);
        mp[i][j]=temp+'0';
      }
      cout << mp[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    A = np.array(read().split(), dtype=np.int64).reshape(N,N)

    INF = 10**15
    ans = 0
    for i in range(N):
        B = A[i,:] + A
        np.fill_diagonal(B, INF)
        B[:,i] = INF
        C = B.min(axis=1)
        C[i] = 0

        if (C < A[i,:]).sum() > 0:
            print(-1)
            exit()
        else:
            index = C > A[i,:]
            ans += A[i, index].sum()

    print(ans // 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23548
st = input()
start = 0
ok = True
while start < len(st):
    if st[start] == 'd':
        if st[start: start + 5] == 'dream':
            if st[start: start + 7] == 'dreamer':
                if st[start: start + 11] == 'dreameraser':
                    start += 11
                elif st[start: start + 10] == 'dreamerase':
                    start += 10
                else:
                    start += 7
            else:
                start += 5
        else:
            ok = False
            break
    elif st[start] == 'e':
        if st[start: start + 5] == 'erase':
            if st[start: start + 6] == 'eraser':
                start += 6
            else:
                start += 5
        else:
            ok = False
            break
    else:
        ok = False
        break
if ok:
    print("YES")
else:
    print("NO")



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

int main() {
  int n,a;
  cin >> n;
  string s[n],okita;
  int t[n],sum=0;
  r(i,n){
    cin >> s[i] >> t[i];
  }
  cin>>okita;
 r(i,n)if(s[i]==okita)a=i;
 for(int i=a+1;i<n;i++)sum+=t[i];
  cout<<sum<<endl;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MOD 1000000007

double dp[3005][3005];

int main(){
    int n; cin >> n;
    rep(j,3005) rep(i,1600) dp[j][i] = 0.0;
    vector<double> p(n); rep(i,n) cin >> p[i];
    dp[0][0] = 1.0;
    double ans = 0.0;
    rep(i,n){
        rep(j, i+1){
            dp[i+1][j] += (1 - p[i]) * dp[i][j];
           // if(j+1 > n / 2) ans += p[i] * dp[i][j];
            dp[i+1][j+1] +=  p[i] * dp[i][j];
        }
    }
    rep(i,n+1) if(i > n / 2) ans += dp[n][i];
    printf("%.16lf\n", ans);
    return 0;
}

Measured memory_bytes: 70144
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t,ans="";
	cin>>s>>t;
	if (s.size()<t.size()) {
		cout<<"UNRESTORABLE";
		return 0;
	}
	for (int i=0;i<=s.size()-t.size();i++){
		string s1=s;
		int k=i,j=0;
		while (j<t.size()){
			if (s1[k]=='?') s1[k]=t[j];
			else if (s[k]!=t[j]) break;
			j++;
			k++;
		}
		if (j==t.size()){
			for (int l=0;l<s1.size();l++){
				if (s1[l]=='?') s1[l]='a';
			}
			if (ans=="") ans=s1;
			else ans=min(s1,ans);
		}
	}
	if (ans=="") cout<<"UNRESTORABLE";
	else cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
int main(){

    int n;
    cin >> n;
    vector<ll> hp(n);
    ll min_hp = LINF;
    int index;
    for(int i = 0; i < n; i++){
        ll a;
        cin >> a;
        hp[i] = a;
        if(min_hp > a){
            min_hp = min(min_hp, a);
            index = i;
        }
    }
    while(count(hp.begin(), hp.end(), 0) != n-1){
        for(int i = 0; i < n; i++){
            if(i == index) continue;
            hp[i] %= min_hp;
            if(min_hp > hp[i]){
                if(hp[i] != 0){
                    min_hp = min(min_hp, hp[i]);
                    index = i;
                }
            }
        }
    }
    cout << min_hp << endl;
    return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
sc = []
for _ in range(M):
    sc.append(list(map(int, input().split())))

minn = 10**(N - 1) if 10**(N - 1) > 1 else 0
maxx = 10**(N + 1) - 1
for n in range(minn, maxx):
    n = str(n)
    for si, ci in sc:
        if int(n[si - 1]) != ci:
            break
    else:
        print(n)
        break
else:
    print(-1)


Measured memory_bytes: 3064