akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

pii dir4[4] = {
    {0, 1},
    {1, 0},
    {-1, 0},
    {0, -1},
};

#define INF 100000

int main(void) {
    int row, col;
    cin >> row >> col;

    vector<vector<char>> map(row+2, vector<char>(col+2));
    for(int i = 1; i <= row; i++) {
        string str;
        cin >> str;
        for(int j = 1; j <= col; j++) {
            map[i][j] = (str[j-1] == '.');
        }
    }

    int vs = (row+2) * (col+2);
    vector<vector<int>> graph(vs, vector<int>(vs, INF));
    for(int i = 1; i <= row; i++) {
        for(int j = 1; j <= col; j++) {
            int src = i * (col+2) + j;
            if(!map[i][j]) continue;
            for(auto d: dir4) {
                pii np = make_pair(
                    i + d.first,
                    j + d.second
                );
                if(!map[np.first][np.second]) continue;
                int dst = np.first * (col+2) + np.second;
                graph[src][dst] = 1;
            }
        }
    }
    for(int i = 0; i < vs; i++) graph[i][i] = 0;

    // Warshal Floyd
    for(int k = 0; k < vs; k++) {
        for(int i = 0; i < vs; i++) {
            for(int j = 0; j < vs; j++) {
                if(graph[i][k] == INF) continue;
                if(graph[k][j] == INF) continue;
                int nnew = graph[i][k] + graph[k][j];
                graph[i][j] = min(
                    graph[i][j],
                    nnew
                );
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < vs; i++) {
        for(int j = 0; j < vs; j++) {
            if(graph[i][j] == INF) continue;
            ans = max(ans, graph[i][j]);
        }
    }

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

Measured memory_bytes: 4532
var l,r,min,re,t:int64;
    i,j:longint;
begin
	readln(l,r);
    if r - l + 1 < 2019 then
      begin
        min:=2018; re:=0;
        for i:= l to r - 1 do
          for j:= i + 1 to r do
            begin
              re:= ((i mod 2019) * (j mod 2019)) mod 2019;
              if re < min then min:=re;
            end;  
        t:=r div 2019;
        if (t * 2019 >= l) and (t * 2019 <= r) then min:=0;
      end
    else min:=0;
    write(min);
end.

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

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; }
void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


vector<int64_t> factMemo{ 1,1 }, factInvMemo{ 1, 1 }, invMemo{ 0, 1 };
int curMax{ 1 };


void initTable(int n) {

	factMemo.resize(n + 1);
	factInvMemo.resize(n + 1);
	invMemo.resize(n + 1);

	for (; curMax < n;)
	{
		curMax++;
		factMemo[curMax] = factMemo[curMax - 1] * curMax % MOD;
		invMemo[curMax] = MOD - invMemo[MOD % curMax] * (MOD / curMax) % MOD;
		factInvMemo[curMax] = factInvMemo[curMax - 1] * invMemo[curMax] % MOD;
	}
}


// calculate mod of combination
int64_t comb(int n, int k) {
	if (n < k)
		return 0;
	if (n < 0 || k < 0)
		return 0;

	if (curMax < n)
		initTable(n);

	return factMemo[n] * (factInvMemo[k] * factInvMemo[n - k] % MOD) % MOD;
}


int64_t comb(int64_t n, int64_t k)
{
	return comb((int)n, (int)k);
}


int main()
{
	ll h, w, a, b; cin >> h >> w >> a >> b;

	if (w - b == 1)
	{
		if (h - a == 1) { cout << 1 << endl; return 0; }

		ll ans = comb((h - a - 1) + (w - 1), w - 1);
		cout << ans << endl;
		return 0;
	}
	else if (h - a == 1)
	{
		ll ans = comb((w - b - 1) + a, a) % MOD;
		cout << ans << endl;
		return 0;
	}

	ll ans = comb(b + (h - a - 1), b);
	ans = ans * comb((w - b - 1) + a, a) % MOD;

	REP1O(i, h - a)
	{
		ll tmp = comb(b + (i - 1), b);
		tmp = tmp * comb((w - b - 2) + (h - i), h - i) % MOD;
		ans = (tmp + ans) % MOD;
	}

	cout << ans << endl;
}

Measured memory_bytes: 6168
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
void solve() {
    int n;
    R(n);
    VI a(n);
    int s=0;
    REP(i,n){
        R(a[i]);
        s^=a[i];
    }
    VI an;
    REP(i,n)an.PB(s^a[i]);
    W(an);
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 5116
# XとYの二部グラフの最大マッチング X={0,1,2,...|X|-1} Y={0,1,2,...,|Y|-1}
#   edges[x]: xとつながるYの頂点のset
#   matched[y]: yとマッチングされたXの頂点(暫定)
 
def dfs(v, visited):
    """
    :param v: X側の未マッチングの頂点の1つ
    :param visited: 空のsetを渡す（外部からの呼び出し時）
    :return: 増大路が見つかればTrue
    """
    for u in edges[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or dfs(matched[u], visited):
            matched[u] = v
            return True
    return False
 
 
# 標準入力からのグラフ読み取り
N = int(input())
red_xy = [list(map(int,input().split())) for i in range(N)]
blue_xy = [list(map(int,input().split())) for i in range(N)]

edges = [set() for _ in range(N)]
matched = [-1] * N
 
for i in range(N):
    for j in range(N):
        #x, y = map(int, input().split())
        if red_xy[i][0] < blue_xy[j][0] and red_xy[i][1] < blue_xy[j][1]:
            edges[i].add(j)
 
# 増大路発見に成功したらTrue(=1)。合計することでマッチング数となる
print(sum(dfs(s, set()) for s in range(N)))

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

int main(){
  int a;
  cin >> a;
  if(a<10)
  cout << a << endl;
  else if(a<100)
    cout << 9 << endl;
  else if(a < 1000)
    cout << a-90 << endl;
  else if(a<10000)
    cout << 909 << endl;
  else if(a < 100000)
    cout << a- 9090 << endl;
  if(a==100000)
    cout << 90909 << endl;
  
        
  }
  
    
  

Measured memory_bytes: 256
// Date: 2020-06-13

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
    LL a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(a == b) cout << "YES";
    else if(a < b) {
        if(a + v*t >= b + w*t) cout << "YES";
        else cout << "NO";
    } else {
        if(a - v*t <= b - w*t) cout << "YES";
        else cout << "NO";
    }

    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << 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; }

int c[3][3],a1,a2,a3,b1,b2,b3;

int main(){
    rep(i,3){
        rep(j,3){
            cin>>c[i][j];
        }
    }
    a1 = c[1][0] - c[0][0];
    a2 = c[2][0] - c[1][0];
    a3 = c[0][0] - c[2][0];
    b1=  c[0][1] - c[0][0];
    b2 = c[0][2] - c[0][1];
    b3 = c[0][0] - c[0][2];
    repi(i,1,3){
        if(a1!=c[1][i] - c[0][i]||a2 != c[2][i] - c[1][i]||a3 != c[0][i] - c[2][i]||b1!=  c[i][1] - c[i][0]||b2 != c[i][2] - c[i][1] || b3!= c[i][0] - c[i][2]){
            out("No");
            return 0;
        }
    }
    out("Yes");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>

using namespace std;

typedef pair<string, int> s_i;

bool gj(string a, string b);

int n, m;

int main()
{
    while (cin >> n >> m, n) {
        long long int ans = 0;
        vector<s_i > cls(n);
        for (int i = 0; i < n; i++) {
            string s;
            int a;
            cin >> s >> a;
            cls[i].first = s; cls[i].second = a;
        }
        for (int i = 0; i < m; i++) {
            string s;
            cin >> s;
            for (int j = 0; j < n; j++) {
                if (gj(s, cls[j].first)) {
                    ans += cls[j].second;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

bool gj(string a, string b)
{
    for (int i = 0; i < 8; i++) {
        if (!(a[i] == b[i] || b[i] == '*')) {
            return false;
        }
    }
    return true;
}

Measured memory_bytes: 3136
#include <iostream>
#include <cstring>
using namespace std;
int A[100];
int main()
{
  int N;
  while(cin >> N){
    memset(A,0,sizeof(A));
    for(int i=0; i<N; i++){
      cin >> A[i];
    }
    int count = 0;
    for(int i=0; i<N; i++){
      int min = i;
      for(int j=i; j<N; j++){
        if(A[j] < A[min]) min = j;
      }
      if(min != i){
        int t = A[min];
        A[min] = A[i];
        A[i] = t;
        count++;
      }
    }
    for(int i=0; i<N; i++){
      if(i!=0) cout << " ";
      cout << A[i];
    }
    cout << endl;
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main()
{
   string S ;
    int N , K ;
    cin >> N >> K >> S ;
    K = K - 1 ;
    if(S[K] == 'A')
    {
       S[K] = 'a';
       cout << S << endl;
    }
    if(S[K] == 'B')
    {
        S[K] = 'b';
        cout << S << endl;
    }
    if(S[K] == 'C')
    {
        S[K] = 'c' ;
        cout << S << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
import sys
from operator import itemgetter

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n, q = na()
a = na()
lasts = [-1] * (n+1)
rs = []
for i in range(n):
    if lasts[a[i]] != -1:
        rs.append((lasts[a[i]], i))
    lasts[a[i]] = i

rs.sort(key=itemgetter(0))

qs = []
for i in range(q):
    u = na()
    qs.append((u[0]-1, u[1]-1, i))
qs.sort(key=itemgetter(0))

def addfenwick(ft, i, v):
    if v == 0 or i < 0: return
    i += 1
    while i < len(ft):
        ft[i] += v
        i += i&-i

def sumfenwick(ft, i):
    s = 0
    i += 1
    while i > 0:
        s += ft[i]
        i -= i&-i
    return s

ft = [0] * (n+10)
anss = [0] * q
p = len(rs)-1
for q in qs[::-1]:
    while p >= 0 and rs[p][0] >= q[0]:
        addfenwick(ft, rs[p][1], 1)
        p -= 1
    anss[q[2]] = q[1]-q[0]+1-sumfenwick(ft, q[1])

for v in anss:
    print(v)


Measured memory_bytes: 190100
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
#endif
//BEGIN CUT HERE
template<typename Data, typename T>
struct ReRooting{
  struct Node{
    int to,rev;
    Data data;
    Node(int to,int rev,Data data):to(to),rev(rev),data(data){}
  };

  using F1 = function<T(T, T)>;
  using F2 = function<T(T, Data)>;

  vector<vector<Node> > G;
  vector<vector<T> > ld,rd;
  vector<int> lp,rp;

  const F1 f1;
  const F2 f2;
  const T id;

  ReRooting(int n,const F1 f1,const F2 f2,const T id):
    G(n),ld(n),rd(n),lp(n),rp(n),f1(f1),f2(f2),id(id){}

  void add_edge(int u,int v,Data d){
    G[u].emplace_back(v,(int)G[v].size(),d);
    G[v].emplace_back(u,(int)G[u].size()-1,d);
  }

  T dfs(int v,int p){
    while(lp[v]!=p&&lp[v]<(int)G[v].size()){
      auto &e=G[v][lp[v]];
      ld[v][lp[v]+1]=f1(ld[v][lp[v]],f2(dfs(e.to,e.rev),e.data));
      lp[v]++;
    }
    while(rp[v]!=p&&rp[v]>=0){
      auto &e=G[v][rp[v]];
      rd[v][rp[v]]=f1(rd[v][rp[v]+1],f2(dfs(e.to,e.rev),e.data));
      rp[v]--;
    }
    if(p<0) return rd[v][0];
    return f1(ld[v][p],rd[v][p+1]);
  }

  vector<T> build(){
    for(int i=0;i<(int)G.size();i++){
      ld[i].assign((int)G[i].size()+1,id);
      rd[i].assign((int)G[i].size()+1,id);
      lp[i]=0;
      rp[i]=(int)G[i].size()-1;
    }
    vector<T> res;
    for(int i=0;i<(int)G.size();i++){
      res.emplace_back(dfs(i,-1));
    }
    return res;
  }
};
//END CUT HERE
#ifndef call_from_test
struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed YUKI_768(){
  int n;
  cin>>n;
  auto f1=[](int a,int b){return max(a,0)+max(b,0);};
  auto f2=[](int a,int d){return d-a;};
  ReRooting<int, int> G(n,f1,f2,0);
  for(int i=1;i<n;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G.add_edge(a,b,1);
  }
  auto res=G.build();
  vector<int> ans;
  for(int i=0;i<n;i++)
    if(1-res[i]>0) ans.emplace_back(i);
  cout<<ans.size()<<"\n";
  for(int x:ans) cout<<x+1<<"\n";
  cout<<flush;
  return 0;
};
/*
  verified on 2019/03/04
  https://yukicoder.me/problems/no/768
*/

signed DP_V(){
  int n,m;
  cin>>n>>m;
  auto f1=[m](int a,int b)->int{return (long long)a*b%m;};
  auto f2=[m](int a,int d)->int{return (a+d)%m;};
  ReRooting<int, int> G(n,f1,f2,1);
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    G.add_edge(x,y,1);
  }
  auto ans=G.build();
  for(int x:ans) cout<<x<<endl;
  return 0;
}
/*
  verified on 2019/10/15
  https://atcoder.jp/contests/dp/tasks/dp_v
*/

signed main(){
  //YUKI_768();
  DP_V();
  return 0;
}
#endif


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

#define int long long
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define endl "\n"
#define E "\n"
#define show(arr) REP(i,arr.size()){cout<<arr[i]<<" ";}
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
const int MAX = 1e18;

#define N 5010

int sum(int x){
    int s=0;
    while(x>0){
        s+=x%10;
        x/=10;
    }
    return s;
}

void solve()
{
    string x;
    cin>>x;
    int i=0,s=0;
    REP(j,x.length()){
        if (x[j]=='W'){
            s+=abs(j-i);
            i++;
        }
    }
    cout<<s;
}

signed main()
{
    int t=1;
    //cin>>t;
    WL(t)solve();

    return 0;
}




Measured memory_bytes: 3736
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
//int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	int w,a,b;
	cin>>w>>a>>b;
	if(a<=b){
		if(a+w>=b)cout<<0<<endl;
		else cout<<b-a-w<<endl;
	}else{
		if(b+w>=a)cout<<0<<endl;
		else cout<<a-b-w<<endl;
	}
	return 0;
}

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

table = [[0] * 10 for _ in range(10)]

for i in range(1, n + 1):
    sentou = int(str(i)[0])
    matsubi = int(str(i)[-1])
    table[sentou][matsubi] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += table[i][j] * table[j][i]

print(ans)


Measured memory_bytes: 3060
#include<stdio.h>

int main(void){

int ai,n,i,b,s;

double w;

b=-1000000;

s=1000000;

scanf("%d",&n);

for(i=0;i<n;i++){

scanf("%d",&ai);

if(ai<s){

s=ai;

}

if(b<ai){

b=ai;

}

w=w+ai;

}

printf("%d %d %0.lf\n",s,b,w);

return 0;

} 

Measured memory_bytes: 636
#include <stdio.h>
char s[300000];
int main(){
  int n,i,count=0,count_min;
  
  scanf("%d",&n);
  scanf("%s",s);
  
  for(i=1;i<n;i++){
    if(s[i]=='E'){
      count++;
    }
  }
  count_min=count;
  
  for(i=1;i<n;i++){
    if(s[i-1]=='W'){
      count+=1;
    }
    if(s[i]=='E'){
      count-=1;
    }
    
    if(count<count_min){
      count_min=count;
    }
  }
  
  printf("%d",count_min);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////

int main() {
    ll n, d; cin >> n >> d;
    ll ans = 0;
    rep(i, 0, n){
        ll x, y; cin >> x >> y;
        if(x*x + y*y <= d*d) ans++;
    }
    co(ans);

    return 0;
}




Measured memory_bytes: 3628
{-# OPTIONS_GHC -O #-}

import Data.List (scanl, unfoldr, foldl')
import qualified Data.ByteString.Char8 as B
import qualified Data.IntSet as S

import Control.Monad
import Control.Monad.ST
import Data.STRef
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV

msort :: MV.STVector s Int -> MV.STVector s Int -> (Int,Int) -> STRef s Int -> ST s ()
msort xv buf (s,e) ra
  | n == 1 = return ()
  | True = do
    msort xv buf lr ra
    msort xv buf rr ra
    forM_ [s..e-1] $ \i -> MV.unsafeRead xv i >>= MV.unsafeWrite buf i
    ac <- msort2 xv buf s lr rr 0 0
    modifySTRef' ra (+ac)
  where
    n = e - s
    m = s + (n+1) `div` 2
    lr@(ls,le) = (s,m)
    rr@(rs,re) = (m,e)
--
msort2 :: MV.STVector s Int -> MV.STVector s Int -> Int -> (Int,Int) -> (Int,Int) -> Int -> Int -> ST s Int
msort2 xv buf s (ls,le) (rs,re) ra rc
  | ls==le && rs==re = return ra
  | rs==re = MV.unsafeRead buf ls >>= MV.unsafeWrite xv s >> msort2 xv buf (s+1) (ls+1,le) (rs,re) (ra+rc) rc
  | ls==le = MV.unsafeRead buf rs >>= MV.unsafeWrite xv s >> msort2 xv buf (s+1) (ls,le) (rs+1,re) ra (rc+1)
  | True = do
    l <- MV.unsafeRead buf ls
    r <- MV.unsafeRead buf rs
    if l<=r
      then MV.unsafeWrite xv s l >> msort2 xv buf (s+1) (ls+1,le) (rs,re) (ra+rc) rc
      else MV.unsafeWrite xv s r >> msort2 xv buf (s+1) (ls,le) (rs+1,re) ra (rc+1)

invc ss = runST $ do
  v <- V.unsafeThaw $ V.fromList ss :: ST s (MV.STVector s Int)
  let len = MV.length v
  ra <- newSTRef (0::Int)
  buf <- MV.new len :: ST s (MV.STVector s Int)
  msort v buf (0, len) ra
  readSTRef ra

si as x = invc $ scanl (\ac a->if a>=x then ac+1 else ac-1) 0 as

bsearch f (a,b)
  | a+1 == b = a
  | f m  = bsearch f (m,b)
  | True = bsearch f (a,m)
  where m = (a + (b-a)`div`2)

ff av as tn x = niv >= (tn+1)`div`2
  where
    niv = (-) tn $ si as $ av V.! x

main=do
  n<-readLn::IO Int
  as<-unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine::IO[Int]
  let av = V.fromList $ S.toAscList $ S.fromList as
  let tn = (n*(n+1))`div`2
  print $ (V.!) av $ bsearch (ff av as tn) (-1,V.length av)

Measured memory_bytes: 30076
#include<stdio.h>
#define MAX 100000

typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P){
  int i=0, j;
  for( j = 0 ; j < k ; j++ ){
    llong s = 0;
    while( s + T[i] <= P ){
      s += T[i];
      i++;
      if( i == n ) return n;
    }
  }
  return i;
}

int solve(){
  llong l = 0;
  llong r = 100000 * 10000;
  llong mid;
  while( r - l > 1 ){
    mid = ( l + r ) / 2;
    int v = check(mid);
    if( v >= n ) r = mid;
    else l = mid;
  }
  return r;
}

int main(){
  int i;
  scanf("%d%d",&n, &k);
  for( i = 0 ; i < n ; i++ ){
    scanf("%d", &T[i]);
  }
  llong ans = solve();
  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 2608
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		  Scanner sc = new Scanner(System.in);
	         
          int S = sc.nextInt();
      	  int W = sc.nextInt();
      if(S<=W){
        System.out.println("unsafe");
      }else{
        System.out.println("safe");
      }
    }
}

Measured memory_bytes: 35708
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  string str,sub;
  cin >> str;
  int ii,len,val;
  int min = 100000;
  len = str.length();
  for(ii=0;ii<=len-1-2;ii++){
	sub = str.substr(ii,3);
	val = atoi(sub.c_str());

	if(abs(val - 753) < min){
	  min = abs(val - 753);
	}
	
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int num[3];
	int i, j;
	scanf("%d %d %d", &num[0], &num[1], &num[2]);
	for(i = 0; i < 3; i++){
		if(i < 2){
			if(num[i] > num[i + 1]){
				j = num[i + 1];
				num[i + 1] = num[i];
				num[i] = j;
			}
		}else{
			if(num[0] > num[1]){
				j = num[0];
				num[0] = num[1];
				num[1] = j;
			}
		}
	}
	printf("%d %d %d\n", num[0], num[1], num[2]);
	return 0;
}

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

int main(){
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> arr(n+1, k);

    //for(int i=0; i<n+1; i++){
        //cout<<arr[i]<<" ";
    //}
    //cout<<endl;
    int Q = q;

    while(Q--){
        int i;
        cin>>i;
        arr[i]++;
    }

    for(int i=1; i<n+1; i++){
        //cout<<arr[i]<<" ";
        arr[i] = arr[i] - q;
    }
    //cout<<endl;

    for(int i=1; i<n+1; i++){
        if(arr[i] <= 0){
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }
    }


}


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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn dfs(pos: usize, par: usize, sum: usize, graph: &Vec<Vec<usize>>, cost: &mut Vec<usize>) {
    cost[pos] += sum;
    for &to in &graph[pos] {
        if to == par {
            continue;
        }
        dfs(to, pos, cost[pos], graph, cost);
    }
}

fn main() {
    input! {
        n: usize,
        q: usize,
        edges: [(usize1, usize1); n-1],
        queries: [(usize1, usize); q],
    }
    let mut graph = vec![vec![]; n];
    let mut cost = vec![0; n];
    for &(f, t) in &edges {
        graph[f].push(t);
        graph[t].push(f);
    }
    for &(p, c) in &queries {
        cost[p] += c;
    }
    dfs(0, 0, 0, &graph, &mut cost);
    for i in 0..n {
        println!("{}", cost[i]);
    }
}


Measured memory_bytes: 41468
<?php
//Request Question
function getq($get_word=null){
	if($get_word===null){
		return str_replace("\n","",fgets(STDIN));
	}else if($get_word===1){
		return explode(" ",str_replace("\n","",fgets(STDIN)));
	}
}

/*		START		*/
$b=0;
$c=getq(1);
for ($i=$c[0]; $i <= $c[1]; $i++) {
	if($i==strrev($i)){
		$b++;
	}
}
echo "$b\n";
?>

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

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n=len(s);
    ll now=1;
    vector<vector<ll> > dp(n+1,vector<ll>(13,0));
    dp[0][0]=1;
    for(ll i=n-1;i>=0;i--){
      //if(i==0) cout<<now<<endl;
      if(s[i]=='?'){
        rep(j,10)rep(k,13){
          dp[n-i][k]+=dp[n-i-1][(k-(j*now)%13+13)%13];
          dp[n-i][k]%=mod;
          //cout<<j<<' '<<n-i-1<<' '<<(k-(j*now)%13+13)%13<<' '<<dp[n-i-1][(k-(j*now)%13+13)%13]<<' '<<endl;
        }
      }else{
        ll cnt=(ll)s[i]-'0';
        rep(k,13){
          dp[n-i][k]+=dp[n-i-1][(k-(cnt*now)%13+13)%13];
          dp[n-i][k]%=mod;
        }
      }
      now*=10;
      now%=13;
    }
    //rep(i,13) cout<<i<<' '<<dp[3][i]<<endl;
    cout<<dp[n][5]<<endl;
}

Measured memory_bytes: 13648
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define INF (1<<29)
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=100;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int N;
string s;
bool flag[MAX+2]; //)が(とセットならtrue
deque<char> dq;

void check1(int i){
    for(int j=i+1;j<s.size();j++){
        if(s[j]==')'&&!flag[j]) {
            flag[j]=true;
            return;
        }
    }
    dq.push_back(')');
}


void solve(){
    for(int i=0;i<s.size();i++){
        if(s[i]=='(') check1(i);
        else if(!flag[i]) dq.push_front('('); //（とセットでない
    }
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>N>>s;
    
    for(int i=0;i<s.size();i++){
        dq.push_back(s[i]);
    }
    solve();
    
    for(auto itr=dq.begin();itr!=dq.end();itr++){
        cout<<*itr;
    }
    cout<<"\n";
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[55],ans,k;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=n;i>n-k;i--)
		ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef int                sint;
#define int                long long
#define ll                 long long
#define endl               '\n'
#define PI                 3.14159265358979323846
#define all0(a)            memset(a,0,sizeof(a))
#define all1(a)            memset(a,-1,sizeof(a))
#define all(v)             v.begin(),v.end()
#define rep(i,a,b)         for(int i=a;i<b;i++)
#define repr(i,a,b)        for(int i=a-1;i>=b;i--)
#define lc(x)              x<<1
#define rc(x)              x<<1|1
#define tm                 (tl+tr)/2
#define pb                 push_back
#define bpc(a)             __builtin_popcount(a)
#define x                  first
#define y                  second
#define xx                 first.first
#define xy                 first.second
#define yx                 second.first
#define yy                 second.second
#define sz(n)              (int)(n.size())
#define min3(a,b,c)        min(a,min(b,c))
#define max3(a,b,c)        max(a,max(b,c))
#define IOS                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define hell               1000000007
#define dec(a)             fixed<<setprecision(a)
#define MAXN               (sint)(1e5+9)

inline int mod(int x,int p = hell) {return (x < 0?(x%p)+p:x%p);}

int ans[MAXN];

int seg[MAXN<<2];

void dolazy(int v)
{
  seg[lc(v)] += seg[v];
  seg[lc(v)] %= hell;
  seg[rc(v)] += seg[v];
  seg[rc(v)] %= hell;
  seg[v] = 0;
}

void update(int v,int tl,int tr,int l,int r,int x)
{
  if(l > r) return;
  if(tl == l && tr == r)
  {
    seg[v] += x;
    seg[v] %= hell;
    return;
  }
  dolazy(v);
  update(lc(v),tl,tm,l,min(r,tm),x);
  update(rc(v),tm+1,tr,max(l,tm+1),r,x);
}

void pushdown(int v, int tl, int tr)
{
  if(tl == tr)
  {
    ans[tl] += seg[v];
    ans[tl] %= hell;
    seg[v] = 0;
    return;
  }
  dolazy(v);
  pushdown(lc(v), tl, tm);
  pushdown(rc(v), tm+1, tr);
}


int solve()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  ans[0] = 1;
  for(int i=0;i<n;i++)
  {
    if(a[i] == 0)
      continue;
    for(int j=0;j<=k;j++)
    {
      update(1, 0, k, j+1, min(j+a[i], k), ans[j]);
    }
    pushdown(1, 0, k);
  }
  cout<<ans[k]<<endl;
  return 0;
}

signed main()
{
  IOS;
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int tc=1;
  // cin>>tc;
  for(int i=1;i<=tc;i++)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 6472
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_075_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(5).
    01 H      PIC 9(2).
    01 W      PIC 9(2).

    01 field1.
        03 field11 OCCURS 50.
            05 field    PIC X(50).

    01 ln     PIC X(50).

    01 MARK1  PIC X(1) VALUE '#'.
    01 MARK2  PIC X(1) VALUE SPACE.

    01 x      PIC 9(2).
    01 y      PIC 9(2).

    01 nx     PIC 9(2).
    01 ny     PIC 9(2).

    01 i      PIC 9(18).
    01 j      PIC 9(18).

    01 k      PIC 9(1).

    01 dx1.
        03 dx11 OCCURS 8.
            05 dx    PIC S9(1).

    01 dy1.
        03 dy11 OCCURS 8.
            05 dy    PIC S9(1).

    01 cnt    PIC 9(1).

PROCEDURE                        DIVISION.
MAIN.
*> X座標
*> 下、右、上、左、右下、右上、左下、左上
MOVE  0 TO dx(1).
MOVE  1 TO dx(2).
MOVE  0 TO dx(3).
MOVE -1 TO dx(4).
MOVE  1 TO dx(5).
MOVE  1 TO dx(6).
MOVE -1 TO dx(7).
MOVE -1 TO dx(8).

*> Y座標
*> 下、右、上、左、右下、右上、左下、左上
MOVE  1 TO dy(1).
MOVE  0 TO dy(2).
MOVE -1 TO dy(3).
MOVE  0 TO dy(4).
MOVE  1 TO dy(5).
MOVE -1 TO dy(6).
MOVE  1 TO dy(7).
MOVE -1 TO dy(8).

    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO H W.

    PERFORM VARYING i FROM 1 BY 1 UNTIL H < i
        ACCEPT field(i)
    END-PERFORM.

    PERFORM VARYING i FROM 1 BY 1 UNTIL H < i
        PERFORM VARYING j FROM 1 BY 1 UNTIL W < j
            MOVE i TO x
            MOVE j TO y
            MOVE 0 TO cnt

            IF field(x)(y:1) = MARK1 THEN
                STRING
                    ln(1:FUNCTION STORED-CHAR-LENGTH(ln))
                    MARK1 DELIMITED BY SIZE
                    INTO ln
                END-STRING
            ELSE
                PERFORM VARYING k FROM 1 BY 1 UNTIL 8 < k
                    COMPUTE nx = x + dx(k)
                    COMPUTE ny = y + dy(k)

                    IF nx < 1 OR H < nx
                        OR ny < 1 OR W < ny THEN
                            CONTINUE
                    ELSE
                        IF field(nx)(ny:1) = MARK1 THEN
                            ADD 1 TO cnt
                        END-IF
                    END-IF
                END-PERFORM

                STRING
                    ln(1:FUNCTION STORED-CHAR-LENGTH(ln))
                    cnt DELIMITED BY SIZE
                    INTO ln
                END-STRING
            END-IF
        END-PERFORM
        DISPLAY ln
        MOVE SPACE TO ln
    END-PERFORM.

    STOP RUN.


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define INFTY 999999


int main(void){
    int N,A,B;
    scanf("%d %d %d", &N, &A, &B);

    int* P;
    NEW(P,N+1);

    //ciがi問目になれる問題の個数
    int c1=0;
    int c2=0;
    int c3=0;

    for(int i=1;i<=N;i++){
        scanf("%d",&P[i]);
        //P[i]にPiが入る(iは1~N)
        if(P[i]<=A){
            c1++;
        }
        else if(P[i]>A&&P[i]<=B){
            c2++;
        }
        else{
            c3++;
        }
    }

    int ans;

    if(c1<c2){
        if(c1<c3){
            ans=c1;
        }
        else{
            ans=c3;
        }
    }
    else{
        if(c2<c3){
            ans=c2;
        }
        else{
            ans=c3;
        }
    }

    printf("%d\n",ans);
    
    return 0;
    
}


Measured memory_bytes: 128
#include<iostream>
#include<utility>
#include<vector>
#include <algorithm>
int main(){
    unsigned long long int h;
    std::cin>>h;
    unsigned long long int nibeki = 1;
    int bekic = 0;
    while(nibeki < h){
        nibeki *= 2;
        ++bekic;
    }
    unsigned long long int ans = 1;
    if(nibeki != h){
        --bekic;
    }
    for(int i = 0;i < bekic;i++){
        ans *=2;
        ans += 1;
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#!/bin/ruby
$str=""
$x=0
def rec
  if $str[$x]=='[' then
    a=[]
    $x+=1
    while $str[$x]!=']'
      a<< rec
    end
    $x+=1
    return a.sort[0...a.size/2+1].reduce(&:+)
  else
    d=0
    while $str[$x]!=']'
      d=d*10+$str[$x].ord-'0'.ord
      $x+=1
    end
    return d/2+1
  end
end
    
n=gets.to_i
n.times do
  $str=gets
  $x=0
  puts rec
end

Measured memory_bytes: 6148
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }






void solve() {
    ll n,k;
    cin>>n>>k;
    ll ans=n;
    rep(i,10000000){
        if(n>k)n=abs(n%k);
        else n=abs(n-k);
        chmin(ans,n);
    }
    cout<<ans<<endl;

}





signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    solve(); 


    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <climits>
#include <numeric>
#include <cstring>
using namespace std;

typedef long long LL;
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007LL

int main(){
	string a, b, c;
	LL dp1[20] = {}, dp2[2] = {};

	while(cin >> a >> b >> c){
		dp2[0] = 1;
		dp2[1] = 0;

		for(int i = a.size() - 1; i >= 0; --i){
			memset(dp1, 0, sizeof dp1);

			for(int p = !i; p <= 9; ++p)
			for(int q = !i; q <= 9; ++q){
				if(a[i] != '?' && p + '0' != a[i]){
					continue;
				}
				if(b[i] != '?' && q + '0' != b[i]){
					continue;
				}

				for(int k = 0; k < 2; ++k){
					LL &x = dp1[p + q + k];
					x = (x + dp2[k]) % MOD;
				}
			}
			
			int dig = c[i] - '0';
			if(c[i] == '?'){
				dp2[0] = accumulate(dp1, dp1 + 10, 0LL) % MOD;
				dp2[1] = accumulate(dp1 + 10, dp1 + 20, 0LL) % MOD;
			}
			else{
				dp2[0] = dp1[dig];
				dp2[1] = dp1[dig + 10];
			}
			
			if(i == 0){
				LL ans = 0;
				if(c[0] == '?'){
					ans = accumulate(dp1 + 1, dp1 + 10, 0LL) % MOD;
				}
				else{
					ans = dp1[dig];
				}
				cout << ans << endl;
			}
		}
	}
}

Measured memory_bytes: 1180
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

const int maxn = 4000 + 3;
char str[maxn];

int n;
vector<int> rgb[3];

typedef long long ll;

void pre() {
  rgb[0].clear();
  rgb[1].clear();
  rgb[2].clear();
  for (int i = 1; i <= strlen(str + 1); i++)
    switch (str[i]) {
      case 'R': rgb[0].push_back(i); break;
      case 'G': rgb[1].push_back(i); break;
      case 'B': rgb[2].push_back(i); break;
    }
}

int bs(const vector<int>& arr, int first, int last, int value) {
  while (first < last) {
    int mid = first + ((last - first) >> 1);
    if (arr[mid] < value) first = mid + 1;
    else last = mid;
  }
  return first;
}

//rgb: 111
inline int mask(char c) {
  if (c == 'R') return 4;
  else if (c == 'G') return 2;
  else return 1;
}

inline int unmask(int v) {
  for (int i = 0; i < 3; i++)
    if (v & (1 << i)) return 2 - i;
}

ll solve() {
  ll ans = 0LL;
  pre();
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      if (str[i] == str[j]) continue;
      int v = 7;
      v = (v & (7 - mask(str[i])));
      v = (v & (7 - mask(str[j])));
      int idx = unmask(v);
      if (!rgb[idx].size()) continue;
      int where = bs(rgb[idx], 0, rgb[idx].size(), j + 1);
      if (where < rgb[idx].size()) {
        int buf = rgb[idx].size() - where;
        int flg = bs(rgb[idx], 0, rgb[idx].size(), j + j - i);
        if (flg < rgb[idx].size() && rgb[idx][flg] == j + j - i) buf -= 1;
        ans += ll(buf);
      }
    }
  return ans;
}

int main() {
  //freopen("input.txt", "r", stdin);
  while (~scanf("%d", &n)) {
    memset(str, 0, sizeof(str));
    scanf("%s", str + 1);
    printf("%lld\n", solve());
  }
  return 0;
}


Measured memory_bytes: 3236
def main():
    N, M = map(int, input().split())
    std = []
    for _ in range(N):
        a, b = map(int, input().split())
        std.append([a, b])
    chk = []
    for _ in range(M):
        c, d = map(int, input().split())
        chk.append([c, d])
    for i in range(N):
        min_d = float('inf')
        togo = None
        for j in range(M):
            d = abs(std[i][0]-chk[j][0]) + abs(std[i][1]-chk[j][1])
            if d < min_d:
                min_d = d
                togo = j+1
        print(togo)

if __name__ == '__main__':
    main()

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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int l = 0;
    int r = 0;
    cin >> l >> r;
    
    sum += (r - l) + 1;
  }
  cout << sum<< endl;

  return 0;
}


Measured memory_bytes: 256
data1 = int(input())
data2 = int(input())
if (data1 == 1 and data2 == 2) or (data1 == 2 and data2 == 1):
    print(3)
elif (data1 == 1 and data2 == 3) or (data1 == 3 and data2 == 1):
    print(2)
elif (data1 == 2 and data2 == 3) or (data1 == 3 and data2 == 2):
    print(1)


Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, H: "List[int]"):
    ## 右側に2以上低いものがあったら不可能

    cur_max = 0
    for i in range(N):
        if cur_max - H[i] >= 2:
            print(NO)
            return 
        cur_max = max(cur_max,H[i])
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15288
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll P = 998244353;
int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  ll k;std::cin >> k;

  vector<ll> box;
  vector<ll> accum;
  ll cnt = 0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0') box.push_back(cnt), cnt = 0;
    else cnt++;
    if(i==s.size()-1) box.push_back(cnt);
  }
  for(int i=0;i<box.size();i++){
    ll tmp = (i!=0?accum[i-1]:0) + box[i];
    accum.push_back(tmp);
  }
  ll m = box.size();
  k = min(k, accum[m-1]);
  vvvl dp = VVV(m+1, accum[m-1]+1, k+1, 0);

  dp[0][0][0] = 1;
  for(int i=1;i<=m;i++){ //i箱
    ll min_num = accum[i-1];
    for(int j=min_num;j<=accum[m-1];j++){ //総和がj
      for(int l=0;l<=k;l++){ // 操作回数がk
        //r追加
        //box[i-1]追加までは無料
        //それ以上はr-box[i-1]コスト
        for(int r=0;r<=j;r++){
          ll cost = max(0LL, r-box[i-1]);
          if(cost>l) break;
          dp[i][j][l] = (dp[i][j][l] + dp[i-1][j-r][l-cost])%P;
        }
      }
    }
  }
  ll ans = 0;
  for(int i=0;i<=k;i++) ans = (ans + dp[m][accum[m-1]][i])%P;
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 31052