akhauriyash/Code-Regression huggingface dataset:
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools, random
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right; sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0;  tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

n = i()
#uvw
x = mi(n - 1)

routedi = {}
for i in range(n + 1):
    routedi[i] = []
for i in range(n - 1):
    routedi[x[i][0]].append([x[i][1], x[i][2]])
    routedi[x[i][1]].append([x[i][0], x[i][2]])

parli = [-1] * (n + 1)#親を保持
ansli = [-1]*(n + 1)
ansli[1] = 0
po = 1
que = deque()
que.append(1)
while que != deque():
    po = que.popleft()
    for i in routedi[po]:
        if parli[i[0]] == -1:  # 親が来るときは断る
            parli[i[0]] = po
            que.append(i[0])
            if i[1] % 2 == 0:
                ansli[i[0]] = ansli[po]
            else:
                if ansli[po] == 1:
                    ansli[i[0]] = 0
                else:
                    ansli[i[0]] = 1

for i in range(1, len(ansli)):
    print(ansli[i])

Measured memory_bytes: 71104
import java.util.*;

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

        String S = sc.next();

        String ans = S.substring(0, 5) + " " + S.substring(6, 13) + " " + S.substring(14);

        System.out.println(ans);
    }
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll w, a, b;

	cin >> w >> a >> b;

	if (b <= a + w && b + w >= a) {
		cout << 0 << endl;
	}
	else if (b > a + w) {
		cout << b - a - w << endl;
	}
	else if(b + w < a){
		cout << a - b - w << endl;
	}
}

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

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    int N;
    cin >> N;
    vi A(N);
    REP(i,N)cin >> A[i];

    vi ans(N);
    iota(ans.begin(),ans.end(),0);

    auto cmp = [&](int  x, int y){
        return (A[x] < A[y]);
        };

    sort(ans.begin(),ans.end(),cmp);

    REP(i,N-1) cout << ans[i]+1 << " ";
    cout << ans[N-1]+1 << endl;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;
int main(){
    ll X;
    cin >> X;
    ll a;
    ll b;
    a = X/500;
    b = X%500;
    ll c;
    c = b / 5;
    cout <<  a*1000 + c*5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

#define loop(i,first,end) for(int i=(first);i<(end);i++)
#define uint unsigned int
#define ull unsigned long long
#define ll long long
#define vint vector<int>
#define vuint vector<unsigned int>
#define vull vector<ull>
#define vll vector<ll>
#define init(type,var) type var;cin>>var;
#define vinit(vtype,var,n) vtype var(n);loop(i,0,n)cin>>var[i];

const ull MOD = 1000000007ULL;
const ull INF = (ull)(-1LL);

int main(void){
	init(ull, n);
	vinit(vull, h, n);

	bool flag = (h[0] > 0);
	bool yes = true;
	loop(i, 1, n){
		if (h[i - 1] < h[i])flag = true;
		else if (h[i - 1] > h[i]){
			if (h[i - 1] - h[i] == 1 && flag)flag = false;
			else {
				yes = false;
				break;
			}
		}
	}
	cout << (yes ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 1024
local PairingHeap={}

PairingHeap.meld=function(self,a,b)
    if not a then
        return b
    elseif not b then
        return a
    elseif a[1]<b[1] then
        b[4]=a[3]
        a[3]=b
        return a
    else
        a[4]=b[3]
        b[3]=a
        return b
    end
end

PairingHeap.pair=function(self,a)
    local b,c,d,e
    while a do
        c=false
        b=a
        a=a[4]
        b[4]=false
        if a then
            c=a
            a=a[4]   
            c[4]=false
        end
        b=self:meld(b,c)
        b[4]=d
        d=b
    end
    while d do
        e=d
        d=d[4]
        a=self:meld(a,e)
    end
    return a
end

PairingHeap.empty=function(self)
    return not self.root
end

PairingHeap.push=function(self,key,value)
    local root=self.root
    if root and root[1]<key then
        root[3]={
            key,
            value,
            false,
            root[3],
        }
    else
        self.root={
            key,
            value,
            root,
            false,
        }
    end
end

PairingHeap.top=function(self)
	return self.root[2]
end

PairingHeap.pop=function(self)
    local root=self.root
    self.root=self:pair(root[3])
    for i=1,4 do
        root[i]=false
    end
    table.insert(self,root)
end

PairingHeap.join=function(self,other)
    local a=self.root
    local b=other.root
    if a[1]<b[1]then
        b[4]=a[3]
        a[3]=b
    else
        a[4]=b[3]
        b[3]=a
        self.root=b
    end
    return self
end

PairingHeap.new=function(self)
    local obj={}
    setmetatable(obj,{__index=PairingHeap})
    return obj
end

----------

local n=io.read("n")
local a={}
for i=1,3*n do
    a[i]=io.read("n")
end

local lsum={[0]=0}
local minq=PairingHeap:new()
for i=1,n do
    local A=a[i]
    lsum[i]=lsum[i-1]+A
    minq:push(A,A)
end
for i=n+1,2*n do
    local P=minq:top()
    local A=a[i]
    if A>P then
        lsum[i]=lsum[i-1]+A-P
        minq:push(A,A)
        minq:pop()
    else
        lsum[i]=lsum[i-1]
    end
end

local rsum={[0]=0}
local maxq=PairingHeap:new()
for i=1,n do
    local A=a[3*n-i+1]
    rsum[i]=rsum[i-1]+A
    maxq:push(-A,A)
end
for i=n+1,2*n do
    local P=maxq:top()
    local A=a[3*n-i+1]
    if A<P then
        rsum[i]=rsum[i-1]+A-P
        maxq:push(-A,A)
        maxq:pop()
    else
        rsum[i]=rsum[i-1]
    end
end
local max=math.mininteger
for i=n,2*n do
    max=math.max(max,lsum[i]-rsum[3*n-i])
end
print(max)

Measured memory_bytes: 79036
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;

int calcTotal(int* ary, int size, int index, int end)
{
  int total = 0;
  while (index < end && index < size)
  {
    total += ary[index];
    index++;
  }

  return total;
}

void add(int* dtAry, int* termAry, int size, int sqrtN, int index, int val)
{
  int bi, termTotal;
  dtAry[index] += val;
  bi = index / sqrtN;
  termTotal = calcTotal(dtAry, size, bi * sqrtN, bi * sqrtN + sqrtN);
  termAry[bi] = termTotal;
}

int getSum(int* dtAry, int* termAry, int dtSize, int termSize, int sqrtN, int left, int right)
{
  int total = 0;
  if (left / sqrtN == right / sqrtN)
  {
    total = calcTotal(dtAry, dtSize, left, right + 1);
  }
  else
  {
    total += calcTotal(dtAry, dtSize, left, ((left / sqrtN) + 1) * sqrtN);
    total += calcTotal(termAry, termSize, (left / sqrtN) + 1, (right + 1) / sqrtN);
    total += calcTotal(dtAry, dtSize, ((right + 1) / sqrtN) * sqrtN, right + 1);
  }

  return total;
}

int main()
{
  int n, q, s, m, i, com, x, y, sum;
  int *dtAry, *termAry;

  cin >> n >> q;
  
  s = static_cast<int>(sqrt(n));
  m = (n + s - 1) / s;

  dtAry = (int*)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) dtAry[i] = 0;

  termAry = (int*)malloc(sizeof(int) * m);
  for (i = 0; i < m; i++) termAry[i] = 0;

  for (i = 0; i < q; i++)
  {
    cin >> com >> x >> y;
    switch (com)
    {
    case 0:
      add(dtAry, termAry, n, s, x-1, y);
      break;
    case 1:
      sum = getSum(dtAry, termAry, n, m, s, x-1, y-1);
      cout << sum << endl;
      break;
    }
  }

  free(dtAry);
  free(termAry);  
  
  return 0;
}


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

using namespace std;

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

    long long ans = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] < a[i-1]) {
            ans += a[i-1]-a[i];
            a[i] = a[i-1];
        }
    }

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

Measured memory_bytes: 4764
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll n,m;
	ll d[200002],t[200002];

	cin>>n;
	rep(i,n)cin>>d[i];
	cin>>m;
	rep(j,m)cin>>t[j];

	sort(d, d + n );
	sort(t, t + m );

	ll c=0,total=0;
	rep(i,n){
		if(t[c]==d[i]){
			total++;
			c++;
		}
	}
	if(total==m){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <string>
#include <cmath> 
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1e9;
#define put(n) cout<<(n)<<endl
#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()
#define pb(n) push_back(n)

int main(){
    int H,W;
    cin >> H >> W; 

    vector<vector<int>> C(10,vector<int>(10));
    rep(i,10)rep(j,10){
        cin >> C[i][j];
    }  

    rep(mid,10)rep(s,10)rep(e,10){
        C[s][e] = min(C[s][e],C[s][mid] + C[mid][e]);
    }
    
    long ans = 0;
    rep(i,H)rep(j,W){
        int A;
        cin >> A;
        if(A == -1 || A == 1) continue;
        ans += C[A][1];
    }

    cout << ans << endl;
}

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

int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, k;
    cin >> a >> b >> k;
    int cnt  = 0;
    int i = min(a, b);
    while(cnt < k){
        if(a%i==0 && b%i==0){
            cnt++;
            //cout << "i = " << i << endl;
        }
        i--;
    }
    i++;
    cout << i << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    map<ll,ll>mp;
    mp[1]=1;
    mp[3]=1;
    mp[5]=1;
    mp[7]=1;
    mp[8]=1;
    mp[10]=1;
    mp[12]=1;
    mp[4]=2;
    mp[6]=2;
    mp[9]=2;
    mp[11]=2;
    mp[2]=3;
    ll x,y;
    cin>>x>>y;
    if(mp[x]==mp[y])
    cout<<"Yes";
    else
    cout<<"No";}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
bool np[1000010];
vector<int> p;
void build()
{
	np[0]=np[1]=1;
	for (ll i=2;i<=1000000;i++)
	{
		if (np[i]) continue;
		p.push_back(i);
		for (ll j=i*i;j<=1000000;j+=i) np[j]=1;
	}
}
int main()
{
	build();
	cin >>n;
	int it=lower_bound(p.begin(),p.end(),n)-p.begin();
	cout <<p[it];
	return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;

    vector<vector<char>> a(h+2, vector<char>(w+2, '#'));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            char in;
            cin >> in;
            a[i][j] = in;
        }
    }

    for(int i=0; i<=h+1; i++){
        for(int j=0; j<=w+1; j++){
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int m;
  bool a=false;
  for(int i=0;i<s.size()-t.size()+1;i++){
    bool b=true;
    string u=s.substr(i,t.size());
    for(int j=0;j<t.size();j++){
      if(u[j]!=t[j]&&u[j]!='?'){
        b=false;
      }
    }
    if(b){
      m=i;
      a=true;
    }
  }
  if(!a){
    cout << "UNRESTORABLE" << endl;
  }
  else{
    for(int i=0;i<s.size();i++){
      if(s[i]=='?'){
        s[i]='a';
      }
    }
    s.replace(m,t.size(),t);
    cout << s << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<string>
#include<algorithm>
#include<cmath>
#define REP(i,n) for(int i=0; i<int(n); i++)
using namespace std;
int main() {
	string S;
	cin >> S;
	int l = S.length();
	int c = 0;
	for (int i = 0; i < l / 2; i++) {
		if (S[i] != S[l - i - 1]) {
			c += 1;
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()

memo = [0] * N
for i in range(N - 1):
    if S[i : i + 2] == 'AC':
        memo[i + 1] += 1
        
for i in range(N - 1):
    memo[i + 1] += memo[i]
    
for i in range(Q):
    l, r = map(int, input().split())
    print(memo[r - 1] - memo[l - 1])

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

int main() {
    string s;
    ll k,ans=0,tmp=0;
    cin>>s>>k;
    ll n = s.size();
    ll a=1;
    for(int i=0; i<n; i++) {
        if(s[i]==s[i+1]) a++;
        else {
          	if(a == 1) a--;
            ans += a/2;
          	tmp++;
          	a=1;
        }
    }
    if(tmp == 1) cout<<n * k / 2<<endl;
    else if(s.front() == s.back()) {
      	ll fr = 0, ba = 0;
        for(int i=0; i<n; i++) {
            fr++;
            if(s[i] != s[i+1]) break;
        }
        for(int i=n-1; i>=0; i--) {
            ba++;
            if(s[i] != s[i-1]) break;
        }
        cout<<ans * k - (k-1) * ((fr/2) + (ba/2) - (fr+ba)/2)<<"\n";
    }
  	else cout<<ans * k<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, k, q; cin >> n >> k >> q;
  vector<ll> v(n, k-q);
  for(int i=0;i<q;++i) {
    int a; cin >> a;
    a--;
    v[a]++;
  }
  for(int i=0;i<n;++i) {
    if(v[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  bool ok = true;
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0) ok = false;
    }
  }
  if (ok) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int gcd(int a, int b)
{
    if (a < b)
        return gcd(b, a);
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

int main()
{

    int K;
    std::cin >> K;

    int ans = 0;

    for (int i = 1; i <= K; i++)
    {
        for (int j = 1; j <= K; j++)
        {
            for (int k = 1; k <= K; k++)
            {
                int tmp = gcd(i, j);
                ans += gcd(tmp, k);
            }
        }
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);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
using ll = long long;
using namespace std;
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; }
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;}

int main(){
  ll H, W; int M; cin >> H >> W >> M;
  vector<int> hc(H,0);
  vector<int> wc(W,0);
  set<pair<int,int>> st;
  rep(i,M){
    int h,w; cin >> h >> w;
    h--;w--;
    hc[h]++;
    wc[w]++;
    st.insert({h,w});
  }
  int wm=0;
  int hm=0;
  rep(i,H) chmax(hm,hc[i]);
  rep(i,W) chmax(wm,wc[i]);
  ll ans = wm+hm-1;
  vector<int> ww,hh;
  rep(i,H) if(hc[i]==hm) hh.pb(i);
  rep(i,W) if(wc[i]==wm) ww.pb(i);
  if(sz(hh)*sz(ww)>M) ans++;
  else{
    rep(y,sz(hh)){
      rep(x,sz(ww)){
        if(!st.count({hh[y],ww[x]})){
          ans++;
          cout << ans << endl;
          return 0;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 23672
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        students: [(isize, isize); n],
        goals: [(isize, isize); m],
    }

    for i in 0..n {
        let mut checkpoint = 1;
        let mut distance = (students[i].0 - goals[0].0).abs() as usize
            + (students[i].1 - goals[0].1).abs() as usize;
        for k in 0..m {
            let tmp = (students[i].0 - goals[k].0).abs() as usize
                + (students[i].1 - goals[k].1).abs() as usize;
            if tmp < distance {
                distance = tmp;
                checkpoint = k + 1;
            }
        }
        println!("{}", checkpoint);
    }
}


Measured memory_bytes: 2204
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
using namespace std;

#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vector<int>>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define itr(v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fd(i,n)         for(int i=n-1;i>=0;i--)
#define fir(i,a,b)      for(int i=a;i<b;i++)
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);
#define MAXZ            200005
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

bool cmp(int a,int b) {return a>b;}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

// int a[200001],b[200001];

int32_t main()
{
    FIO
    int a,b,c,k; cin>>a>>b>>c>>k;
    int s=0;
    if(k>0){
        if(k>a) {
            s+=a;
            k=k-a;
            // cout<<a<<"\n";
        }
        else{
            s+=k;
            k=0;
        }
    }
    // cout<<s<<"\n";
    if(k>0){
    if(k>b) {
        // s+=a;
        k=k-b;
    }
    else{
        // s+=k;
        k=0;
    }
    }
    if(k>0){
        if(k>c) {
            s=s-c;
            k=k-c;
        }
        else{
            s=s-k;
            k=0;
        }
    }
    cout<<s<<"\n";
    return 0;

}

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

int main(){
  int64_t N,M,X;
  cin >> N >> M >> X;
  vector<int64_t> C(N);
  vector<vector<int64_t>> A(N, vector<int64_t>(M));
  for(int64_t i=0;i<N;i++){
    cin >> C.at(i);
    for(int64_t j=0;j<M;j++){
      cin >> A.at(i).at(j);
    }
  }
  int64_t mn=100000000000;
  for (int tmp = 0; tmp < (1 << 12); tmp++) {
    bitset<12> s(tmp);
    int64_t c=0;
    for(int64_t j=0;j<M;j++){
      int64_t B=0;
      for(int64_t i=0;i<N;i++){
        if(s.test(i)){
          B+=A.at(i).at(j);
        }
      }
      if(B>=X){
        c++;
      }
    }
    if(c==M){
      int64_t d=0;
      for(int64_t i=0;i<N;i++){
        if(s.test(i)){
          d+=C.at(i);
        }
      }
      mn=min(mn,d);
    }
  }
  if(mn==100000000000){
    cout << -1 << endl;
  }else{
    cout << mn << endl;
  }
}

Measured memory_bytes: 3636
import math

a, b, C = map(int,input().split())

S = a * b * (math.sin(math.radians(C))/2)
L = a + b + math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(C)))
h = S*2/a

print(S)
print(L)
print(h)


Measured memory_bytes: 5712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 999;
    rep(i,n-2){
        int num = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
        ans = min(ans,abs(num-753));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <regex>
#include <complex>

using ll = long long;
using ull = unsigned long long;
using ld = long double;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

template <class T>
constexpr bool in(T min, T max, T t)
{
    return t >= min && t <= max;
}

template <class T>
constexpr bool nin(T min, T max, T t)
{
    return !in(min, max, t);
}

template <class T>
void ninDebug(T min, T max, T t)
{
    using namespace std;
    if (nin(min, max, t))
    {
        cout << "ERROR" << endl;
    }
}

int main()
{
    using namespace std;
    // cerr.rdbuf(nullptr);

    string w;
    cin >> w;

    auto toLower = [](string s) {
        for (auto& c : s)
        {
            c = tolower(c);
        }
        return s;
    };

    w = toLower(w);

    int ans{};

    while (true)
    {
        string t;
        cin >> t;

        if (t == "END_OF_TEXT")
            break;

        t = toLower(t);

        if (w == t)
            ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;

const int maxN = 4e2 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll modP(ll a, ll b) {return (!b ? 1 : (modP(a, b / 2) * modP(a, b / 2) * (b % 2 ? a : 1)) % MOD);}

ll n, a[maxN], i, j, k;
ll dp[maxN][maxN], sum;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	memset(dp, 63, sizeof dp);
	for (i = 0; i < n; i++){
		cin >> a[i];
		dp[i][i + 1] = 0;
	}
	for (i = 2; i <= n; i++){
		for (j = 0; j <= n - i; j++){
			sum = a[j];
			for (k = j + 1; k < j + i; k++){
				dp[j][j + i] = min(dp[j][j + i], dp[j][k] + dp[k][j + i]);
				sum += a[k];
			}
			dp[j][j + i] += sum;
		}
	}
	cout << dp[0][n] << endl;
	return 0;
}



Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    vii a(n);
    for (ii &x : a) cin >> x.fi >> x.se;
    sort(a.begin(), a.end());
    int j = 0;
    int res = 0;
    priority_queue<int> pq;
    fort(i, 1, m) {
        while (j < (int)a.size() && a[j].fi <= i) {
            pq.push(a[j].se);
            ++j;
        }
        if (!pq.empty()) {
            res += pq.top();
            pq.pop();
        }
    }
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007

int main() {
	ios;
	ll n, k;
	cin>>n>>k;
	ll min, max, ans = 0;
	for (ll i = k; i <= n+1; i++) {
		min = i*(i-1)/2;
		max = n*i - min;
		ans += max - min + 1;
	}
	cout<<ans%hell<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <math.h>
#include <string.h>

#define MAX 1001

int LCS(char *, char *);

int main()
{
  int i, j, q;
  char X[MAX], Y[MAX];
  
  scanf("%d", &q);

  for( i = 0 ; i < q ; i++ ){
    scanf("%s%s", X, Y);
    printf("%d\n", LCS(X, Y));
  }

  return 0;
}

int LCS(char X[], char Y[])
{
  int i, j;
  int c[MAX][MAX];
  int m, n, max=0;
  
  m = strlen(X);
  n = strlen(Y);

  for( i = strlen(X) ; i >= 0 ; i-- ) X[i+1] = X[i];
  for( i = strlen(Y) ; i >= 0 ; i-- ) Y[i+1] = Y[i];
  
  X[0] = ' ';
  Y[0] = ' ';
  
  for( i = 1 ; i <= m ; i++ ) c[i][0] = 0;
  for( j = 1 ; j <= n ; j++ ) c[0][j] = 0;
  
  for( i = 1 ; i <= m ; i++ ){
    for( j = 1 ; j <= n ; j++ ){
      if( X[i] == Y[j] ){
	c[i][j] = c[i-1][j-1] + 1;
      }
      else if( c[i-1][j] >= c[i][j-1] ){
	c[i][j] = c[i-1][j];
      }
      else {
	c[i][j] = c[i][j-1];
      }
      max = fmax(max, c[i][j]);
    }
  }

  return max;
}

Measured memory_bytes: 4524
#include<bits/stdc++.h> 
//compiling code: g++ test.cpp(file) -o script(output) -std=c++11(version) -O2(make it 2x faster)
using namespace std;

int N, AI;
vector<pair<int, int>> A; 

int main(){
    cin >> N;
    for(int i=1; i<=N; i++){
        cin >> AI;
        A.push_back(make_pair(AI, i));
    }
    sort(A.begin(), A.end());
    for(int i=0; i<=N-1; i++){
        cout << A[i].second << " ";
    }
    

    return 0;
}

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

#define N 2000

int main() {

  int n;
  cin>>n;

  int a, max = 0, min = N;
  for (int i = 0; i < n; i++) {
    cin>>a;
    if (max < a) max = a;
    if (min > a) min = a;
  }

  int dis = (max - min) + 1;
  cout<<dis/2<<endl;

  return 0;
}



Measured memory_bytes: 3108
#include<stdio.h>

int main(){

int N,x=0,max=0;
scanf("%d",&N);
char S[N];

for (int i = 0; i < N+1; i++)
{
  scanf("%c",&S[i]);
  if (S[i]=='I'){
    x++;
  }else if (S[i]=='D'){
    x--;
  }
  if (max < x) max = x;
}

printf("%d",max);

return 0;

}

Measured memory_bytes: 1736
/* dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define   endl      '\n'
#define pii         pair<ll ,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)   for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
   ios
   ll n,m,i,j;
   cin>>n>>m;
   if(n==1||m==1)
   {
      if(n==1&&m==1){cout<<"1";return 0;}
      cout<<max(n,m)-2;return 0;
   }else
   {
      ll ans=(n-2)*(m-2);
      cout<<ans;
   }
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define ll long long 
# define skorost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

using namespace std ;
 
ll z , o , ans ;

ll N = 1e4 + 15820 ;

int main(){ skorost ;

	int w , h , n ;

	cin >> w >> h >> n ;

	int wa = w ;

	int ha = h ;

	int a[wa][ha] ;

	for( int i = 0 ; i < wa ; i ++ ){

		for( int j = 0 ; j < ha ; j ++ ){

			a[i][j] = 0 ;

		}

	}

	for( int e = 0 ; e < n ; e ++ ){

		int x , y , ch;

		cin >> x >> y >> ch ;

		for( int i = 0 ; i < wa ; i ++ ){

			for( int j = 0 ; j < ha ; j ++ ){

				if( ch == 1 ){

					if( i + 1 <= x ){

						a[i][j] = 1 ;

					}

				}

				if( ch == 2 ){

					if( i + 1 > x ){

						a[i][j] = 1 ;

					}

				}

				if( ch == 3 ){

					if( j + 1 <= y ){

						a[i][j] = 1 ;

					}

				}

				if( ch == 4 ){

					if( j + 1 > y ){

						a[i][j] = 1 ;

					}

				}

			}

		}

	}

	for( int i = 0 ; i < wa ; i ++ ){

		for( int j = 0 ; j < ha ; j ++ ){

			if(a[i][j] == 0) {

				ans ++ ;

			}

		}

	}

	cout << ans << endl ;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <malloc.h>

int main()
{
	int* A = 0;
	int N = 0;
	int d = 0;
	
	scanf("%d", &N);
	A = (int*)malloc(sizeof(int) * N);

	int c = 0;

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A[i]);
	}
	for (int j = 0; j < N; j++) {
	
		if (A[j] % 2 == 0)
		{
			if (A[j] % 3 == 0 || A[j] % 5 == 0)
				d++;
			else 
			{
			c++;
			break;
			}
		}
	}
	if(c==0)
	printf("APPROVED");
	if(c!=0)
	printf("DENIED");


	
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		String S = sc.next();
		
		String res = "";
		for (int i = 0; i < N; i++) {
			if(i != K-1) {
				res += S.charAt(i);
			}else {
				res += Character.toLowerCase(S.charAt(i));
			}
		}
		System.out.println(res);
		
	}
}


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

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

int main(){

  int n; cin >> n;
  double ans = 0;

  for(int i = 0; i < n; i++)
  {
    float x;
    string u;
    cin >> x >> u;
    
    if(u == "JPY")
      ans += x;
    else
      ans += (380000 * x);

  }

  printf("%.8f\n", ans);  
 
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())

cntW = 0
cntE = 0
sumW =[]
sumE = []
num_of_turn = []

for i in range(N):
    if S[i] == 'W':
        cntW += 1
    elif S[i] == 'E':
        cntE += 1
    sumW.append(cntW)
    sumE.append(cntE)

num_of_turn.append(sumE[N - 1] - sumE[0])

for i in range(1, N - 1):
    num_of_turn.append(sumW[i - 1] + sumE[N - 1] - sumE[i])

num_of_turn.append(sumW[N - 1])

print(min(num_of_turn))


Measured memory_bytes: 32460
fn main(){
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let s = sc.chars();
    if s.len()>=4&&s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'{
        println!("Yes" );
    }else{
        println!("No");
    }

}


pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
int main(int argc, char *argv[]){
        char aorc[4];
        fgets(aorc,4,stdin);
        if(aorc[1] == 'B'){
                printf("ARC\n");
        }else{
                printf("ABC\n");
        }
        return 0;
}

Measured memory_bytes: 1532
//ll _(){
//    ll ans = 0;
//    int n;
//    cin >> n;
//    vl arr(n);
//    cin >> arr;
//    map<ll,ll> cnt;
//    for(ll x : arr)
//        cnt[x] ++;
//    for(auto _ : cnt){
//        ll v,c;
//        tie(v,c) = _;
//        if(c < v)
//            ans += c;
//        else
//            ans += c-v;
//    }
//    return ans;
//}
//
//
#include <map>
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
ll _(){
    ll ans = 0;
    int n;
    cin >> n;
    vl arr(n);
    cin >> arr;
    map<ll,ll> cnt;
    for(ll x : arr)
        cnt[x] ++;
    for(auto _ : cnt){
        ll v,c;
        tie(v,c) = _;
        if(c < v)
            ans += c;
        else
            ans += c-v;
    }
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 7040
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int gcd(int x, int y);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans = pow(3, n);
    int num = 1;
    rep(i, n) {
        if (a[i] % 2 == 0) {
            num *= 2;
        }
        else {
            num *= 1;
        }
    }

    cout << ans - num << endl;
    return 0;
}
/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }






int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    /*
     int n;
     cin >> n;
     vector<int> a(n);
     rep(i, n) cin >> a[i];
     */
    
    int m, d, m2, d2;
    cin >> m >> d >> m2 >> d2;
    if (m2 == m + 1) cout << 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n;
	while (n--) {
		double x1, y1, x2, y2, r1, r2; cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
		double dis = pow(abs(x1 - x2)*abs(x1 - x2) + abs(y1 - y2)*abs(y1 - y2),0.5);
		if (r1 + r2 < dis)cout << 0 << endl;
		else if (abs(r1 - r2) <= dis&&dis <= abs(r1 + r2))cout << 1 << endl;
		else {
			if (dis < r1 - r2)cout << 2 << endl;
			else cout << -2 << endl;
		}
	}
	return 0;
}

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

int main()
{
    int x;
    cin >> x;
    int p = x / 100, q = x % 100;
    int cnt = 0;
    
    for(int i = 5; i >= 1; i--){
        cnt += q / i;
        q %= i;
    
    }

    if(cnt <= p) cout << "1" << endl;
    else cout << "0" << endl;
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  vector<string> vec={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string s;
  cin >> s;
  for(int i=0;i<7;i++){
    if(s==vec[i]){
      cout << 7-i << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  ll  long long
#define rep(k, n)  for(int i=k; i<n;  i++)
#define rep2(k,n)   for(int j=k; j<n;  j++)
using namespace std;

int main(){
    ll h,ans=0;
    int n;
    cin >> h >> n;
    int arr[n];
    rep(0,n) cin >> arr[i];
    rep(0,n) ans += arr[i];
    if(ans>=h) cout << "Yes" << endl;
    else        cout << "No"  << endl;
    return 0;
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 h,w;
  cin >> h >> w;
  vector<string> c(h);
  REP(i,h)cin >> c[i];
  int32 ans = 0;
  REP(k,w-1){
    vector<vector<int32>> cnt(h+1,vector<int32>(h+1,0));
    FOR(i,1,h+1)FOR(j,1,h+1){
      cnt[i][j] = cnt[i-1][j-1];
      if(c[i-1][k] == c[j-1][k+1])++cnt[i][j];
    }

    vector<vector<int32>> dp(h+1,vector<int32>(h+1,inf));
    dp[0][0] = 0;
    REP(i,h+1){
      REP(j,h+1){
        // int32 cnt = 0;
        // REP(m,min(i,j)){
        //   if(c[m+i-min(i,j)][k] == c[m+j-min(i,j)][k+1])++cnt;
        // }
        if(i > 0)
          chmin(dp[i][j],dp[i-1][j] + cnt[i][j]);
        if(j > 0)
          chmin(dp[i][j],dp[i][j-1] + cnt[i][j]);

      }
    }
    ans += dp[h][h];
    // ANS(dp[h][h]);
  }
  ANS(ans);
  return 0;
}

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

int N;
int highest = 0;
int now;
int M;
int ans = 1;

int main()
{
	cin >> M;
	for(int i = 1 ; i <= M; i ++)
	{
		N = i;
		while(1)
		{
			// cout << "debug 2" << endl;
			if(N % 2 == 0)
			{
				N /= 2;
				now ++;
			}
			else
			{
				if(highest < now)
				{
					highest = now;
					ans = i;
				}
				now = 0;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    int D, L;
    cin >> D >> L;

    int cnt = 0;

    cnt += D / L;

    D %= L;

    cout << cnt + D << endl;
    
    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define AC ios::sync_with_stdio(0),cin.tie(0);

int main()
{
    AC
    int n,w,r=0;
    cin>>n>>w;
    vector<ll> dp(100001,1e10);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        int wei,val;
        cin>>wei>>val;
        for(int j=100000;j>=val;j--)
            dp[j]=min(dp[j],dp[j-val]+wei);
    }
    for(int i=1;i<dp.size();i++)
        if(dp[i]<=w) r=i;
    cout<<r<<'\n';
}

Measured memory_bytes: 1024
//********************************************************************//
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define RANGE(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define DFOR(i, a, b) for(int i = a; i > b; --i)
#define DEB(x) cout << #x << ": " << x << endl
#define ALL(v) v.begin(), v.end() 
#define SORT(v) sort(ALL(v))
#define DISPV(v) { for(auto x___: v) cout << x___ << " "; cout << endl; }
#define DISPM(m) { for(auto x____: m){ cout << x____.first << ": " << x____.second << endl; } };
#define DISPMV(m) { for(auto x_____: m){ cout << x_____.first << ": " ;DISPV(x_____.second);} };
using LL = long long;
using VI = vector <int>;
using VL = vector <long long>;
using VVI = vector<VI>;
using VVL = vector <VL>;
using MII = map<int, int>;
using MIVI = map<int, VI>;
using MLL = map<LL, LL>;
int READ_INT(){int temp;cin>>temp;return temp;}      // read an int
LL READ_LONG(){LL temp;cin>>temp;return temp;}      // read a long long
string READ_STRING(){string temp;cin>>temp;return temp;}      // read a string

const int MOD = int(1e9) + 7;
const int INF = 1e9 + 5;
const double PI = acos(-1.0); //M_PI;
const double EPS = 1e-9;
//********************************************************************//

int s;
int dp[2005];

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> s;
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    for(int x = 1; x <= s; ++x){
        for(int i = 3; i <= s; ++i){
            if(x - i >= 0)
                dp[x] = (dp[x] + dp[x-i]) % MOD;
        }
    }
    // for(int i = 1; i <= 10; ++i)
    //     cout << i << ": " << dp[i] << "\n";
    cout << dp[s] << endl;
    return 0;
}



/* complie flags
-Wall -Wextra -pedantic -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector
*/

Measured memory_bytes: 3660