akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

bool judge(vector<string> S){
  int n = sz(S);
  bool ok = true;
  rep(i,n){
    rep(j,n){
      if(i==j)continue;
      ok &= (S[i][j] == S[j][i]);
    }
  }
  return ok;
}

int main() {
  int n;
  cin>>n;
  vector<string> S(n);
  rep(i,n)cin>>S[i];

  int ans =0;
  rep(i,n){
    ans+=judge(S)*n;
    rotate(S.begin(),S.begin()+1,S.end());
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *l;
  struct node *r;
  struct node *p;
  int key;
};

typedef struct node *Node;

Node root;
Node TreeMin(Node x){
}

Node TreeSearch(Node x, int k){
  if(x==NIL||k==x->key) return x;
  if(k<x->key) return TreeSearch(x->l,k);
  else return TreeSearch(x->r,k);
}

Node TreeSuccessor(Node x){
}

void TreeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
}

void TreeInsert(int k){
  Node y=NIL;
  Node x=root;
  Node z;
  z=malloc(sizeof(struct node));
  z->key=k;
  z->l=NIL;
  z->r=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->l;
    else x=x->r;
  }
  z->p=y;
  if(y==NIL) root=z;
  else if(z->key<y->key) y->l=z;
  else y->r=z;
}

void Iorder(Node u){ //Inorder
  if(u!=NIL){
      Iorder(u->l);
      printf(" %d",u->key);
      Iorder(u->r);
  }
}

void Porder(Node u){ //Preorder
  printf(" %d",u->key);
  if(u!=NIL){
    if(u->l!=NIL)Porder(u->l);
    if(u->r!=NIL)Porder(u->r);
  }
}

int main(){
  int n,i,x;
  char array[20];
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",array);
    if(array[0]=='f'){
      scanf("%d",&x);
      Node t = TreeSearch(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    } else if(array[0]=='i'){
      scanf("%d",&x);
      TreeInsert(x);
    } else if(array[0]=='p'){
      Iorder(root);
      printf("\n");
      Porder(root);
      printf("\n");
    } else if(array[0]=='d'){
      scanf("%d",&x);
      TreeDelete(TreeSearch(root,x));
    }
  }
  return 0;
}

Measured memory_bytes: 19364
s=input()
n=len(s)
mod=10**9+7
dp=[[0 for i in range(13)] for j in range(n+1)]
if s[-1]=="?":
    for i in range(10):
        dp[1][i]=1
else:
    p=int(s[-1])
    dp[1][p]=1
for i in range(1,1+n):
    if s[-i]=="?":
        for j in range(10):
            p=j*pow(10,i-1,13)%13
            for k in range(13):
                dp[i][k+p-13]+=dp[i-1][k]
                dp[i][k+p-13]=dp[i][k+p-13]%mod
    else:
        p=int(s[-i])*pow(10,i-1,13)%13
        for k in range(13):
            dp[i][k+p-13]+=dp[i-1][k]
            dp[i][k+p-13]=dp[i][k+p-13]%mod
print(dp[-1][5])

Measured memory_bytes: 67548
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << 60 * (h2 - h1) + m2 - m1 - k << "\n";
    return 0;
}

Measured memory_bytes: 3636
X,N=map(int,input().split())
P=list(map(int,input().split()))
p=[]
for j in range(X*100):
    if j in P:
        a=0
    else:
        p.append(j)
result=1000
answer=1000
for i in range(X*100-N):
    if abs(X-p[i])<result:
        answer=p[i]
        result=abs(X-p[i])
    elif abs(X-p[i])==result and p[i]<=answer:
        answer=p[i]
print(answer)

Measured memory_bytes: 9340
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
S=get_nsp
#S=>0 W=>1
def simulate(init1,init2)
  zoo=array(N,-1)
  zoo[0]=init1
  zoo[1]=init2
  1.upto(N-2) do|i|
    if S[i]=="o"
      zoo[i+1]=(zoo[i]+zoo[i-1])%2
    else
      zoo[i+1]=(zoo[i]+zoo[i-1]+1)%2
    end
  end
  if S[N-1]=="o"
      unless zoo[0]==(zoo[N-2]+zoo[N-1])%2
          return "-1"
      end
  else
      unless zoo[0]!=(zoo[N-2]+zoo[N-1])%2
          return "-1"
      end
  end

  if S[0]=="o"
      unless zoo[1]==(zoo[N-1]+zoo[0])%2
          return "-1"
      end
  else
      unless zoo[1]!=(zoo[N-1]+zoo[0])%2
          return "-1"
      end
  end
  return zoo
end
2.times do|i|
    2.times do|j|
        s=simulate(i,j)
        if s!="-1"
            ans=[]
            s.each do|c|
              if c==1
                  ans<<"W"
              else
                  ans<<"S"
              end
            end
            puts ans.join("")
            exit
        end
    end
end
puts "-1"

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

#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define AI(a,size,n) array<int,size> a;REP(i,n){assert(0<scanf("%d",&a[i]));}
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  INT(n); INT(q);
  vector<int> ans(q, -1);
  vector<tuple<int, int, int>> op;
  REP(n){
    INT(s); INT(t); INT(x);
    op.EB(s - x, 1, x);
    op.EB(t - x, 0, x);
  }
  VI(ds, q);
  REP(i, q){op.EB(ds[i], 2, i);}
  sort(op.begin(), op.end());
  multiset<int> ms;
  for(auto tpl: op){
    int d, x, y; tie(d, x, y) = tpl;
    if (x == 0){
      ms.erase(ms.find(y));
    } else if (x == 1){
      ms.insert(y);
    } else if (!ms.empty()){
      ans[y] = *ms.begin();
    }
  }
  for (int d: ans){printf("%d\n", d);}
  return 0;
}

Measured memory_bytes: 19944
N, M, X = map(int,input().split())

min_cst = -1
C = []
A = []
for i in range(N):
    CA = list(map(int,input().split()))
    C.append(CA[0])
    A.append((CA[1:]))

for i in range(2**N):
    l = [0]*M
    cst = 0
    flag = True
    for j in range(N):
        if (i>>j) & 1:
            cst += C[j]
            for k in range(M):
                l[k] += A[j][k]
    for k in range(M):
        if l[k] < X:
            flag = False
            break
    if flag:
        if cst < min_cst or min_cst == -1:
            min_cst = cst

print(min_cst)

Measured memory_bytes: 68616
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D: Forest
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

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

struct UFT {
  int links[MAX_N], ranks[MAX_N], sizes[MAX_N];
  UFT() {}

  void clear(int n) {
    for (int i = 0; i < n; i++) links[i] = i, ranks[i] = sizes[i] = 1;
  }

  int root(int i) {
    int i0 = i;
    while (links[i0] != i0) i0 = links[i0];
    return (links[i] = i0);
  }

  int rank(int i) { return ranks[root(i)]; }
  int size(int i) { return sizes[root(i)]; }
  bool same(int i, int j) { return root(i) == root(j); }

  int merge(int i0, int i1) {
    int r0 = root(i0), r1 = root(i1), mr;
    if (r0 == r1) return r0;
    if (ranks[r0] == ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      ranks[r0]++;
      mr = r0;
    }
    else if (ranks[r0] > ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      mr = r0;
    }
    else {
      links[r0] = r1;
      sizes[r1] += sizes[r0];
      mr = r1;
    }
    return mr;
  }
};

/* global variables */

UFT uft;
int as[MAX_N];
pii ps[MAX_N];
bool rs[MAX_N];
ll asums[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  int k = 2 * (n - m - 1);
  if (n < k) {
    puts("Impossible");
    return 0;
  }

  if (k == 0) {
    puts("0");
    return 0;
  }
  
  for (int i = 0; i < n; i++) scanf("%d", &as[i]);

  uft.clear(n);

  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (! uft.same(a, b)) uft.merge(a, b);
  }

  for (int i = 0; i < n; i++) ps[i] = pii(as[i], uft.root(i));
  sort(ps, ps + n);

  ll sum = 0;
  asums[0] = 0;
  int l = 0, c = 0;

  for (int i = 0; i < n; i++) {
    int &pai = ps[i].first, &pri = ps[i].second;
    if (! rs[pri]) sum += pai, rs[pri] = true, c++;
    else asums[l + 1] = asums[l] + pai, l++;
  }
  sum += asums[k - c];

  printf("%lld\n", sum);
  return 0;
}



Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int s;
  cin >> s;
  int a,b,c;
  a = s / 3600;
  b = (s - a * 3600) / 60;
  c = s % 60;
  cout << a << ":" << b << ":" << c << endl;
  return 0;
}



Measured memory_bytes: 3096
#include <atcoder/maxflow>
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> grid(N);
    for (int i = 0; i < N; i++) cin >> grid[i];

    atcoder::mf_graph<int> graph(N*M*2+2);
    vector<vector<int>> tiles;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (grid[i][j] == '#') continue;
            int s = i*M+j;
            if (i < N-1 && grid[i+1][j] == '.') {
                int t = (i+1)*M+j;
                if ((i+j)&1) {
                    tiles.push_back({s, t});
                    graph.add_edge(s, t+N*M, 1);
                }else {
                    tiles.push_back({t, s});
                    graph.add_edge(t, s+N*M, 1);
                }
            }
            if (j < M-1 && grid[i][j+1] == '.') {
                int t = i*M+j+1;
                if ((i+j)&1) {
                    tiles.push_back({s, t});
                    graph.add_edge(s, t+N*M, 1);
                }else {
                    tiles.push_back({t, s});
                    graph.add_edge(t, s+N*M, 1);
                }
            }
        }
    }
    int start = N*M*2, goal = start+1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (grid[i][j] == '#') continue;
            if ((i+j)&1) graph.add_edge(start, i*M+j, 1);
            else graph.add_edge(i*M+j+N*M, goal, 1);
        }
    }

    int flow = graph.flow(start, goal);
    vector<char> ansgrid(N*M, '.');
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (grid[i][j] == '#') ansgrid[i*M+j] = '#';
        }
    }

    for (int i = 0; i < (int)tiles.size(); i++) {
        auto e = graph.get_edge(i);
        if (e.flow == 1) {
            int s = tiles[i][0], t = tiles[i][1];
            if (s > t) swap(s, t);
            if (t%M != 0 && s+1==t) {
                ansgrid[s] = '>';
                ansgrid[t] = '<';
            }else {
                ansgrid[s] = 'v';
                ansgrid[t] = '^';
            }
        }
    }
    cout << flow << endl;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cout << ansgrid[i*M+j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 7184
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long int
int main()
{
	string s;
	cin>>s;
	ll l=(int)s.size(),ww=0;
	for(ll i=0;i<l-1;i++)
	{
		if(s[i]!=s[i+1])
		{
			ww++;
		}
	}
	if(ww==0)
	{
		cout<<ww<<endl;
		return 0;
	}
	ll qqq=0;
	for(ll i=0;i<l-1;i++)
	{
		if(s[i]!=s[i+1])
		{
			qqq++;
		}
	}
	if(qqq==1)
	{
		cout<<qqq<<endl;
		return 0;
	}
	ll qq=2,q;
	for(ll i=l-1;i>=1;i--)
	{
		if(s[i]!=s[i-1])
		{
			qq--;
		}
		if(qq==0)
		{
			q=i;
			break;
		}
	}
	q--;
	//cout<<q<<endl;
	ll re=2;
	for(ll i=q;i>=1;i--)
	{
		if(s[i]!=s[i-1])
		{
			re++;
		}
	}
	cout<<re<<endl;
}


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

using namespace std;

int main() {
  int a, b, s[999] = {};
  scanf("%d %d", &a, &b);
  for (int i = 1; i < 1000; i++) {
    s[i] = s[i - 1] + i;
  }
  printf("%d\n", s[b - a] - b);
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
l.sort()
if n%2:
	m=l[n//2][0]
else:
	m=(l[n//2-1][0]+l[n//2][0])/2
l.sort(key=lambda x:-x[1])
if n%2:
	M=l[n//2][1]
else:
	M=(l[n//2-1][1]+l[n//2][1])/2
if n%2:
	print(M-m+1)
else:
	print(int(2*(M-m)+1))

Measured memory_bytes: 55196
# https://atcoder.jp/contests/abc128/submissions/11722664

def main():
    from collections import deque, namedtuple
    from heapq import heappush, heappop
    from operator import attrgetter
    import sys

    input = sys.stdin.readline
    Event = namedtuple('Event', 'pos start end')
    UC = namedtuple('UC', 'pos end')  # UnderConstruction

    N, Q = map(int, input().split())

    events = []
    for _ in range(N):
        s, t, x = map(int, input().split())
        e = Event(pos=x, start=s - x, end=t - x)  # 時間[s-x,t-x)にpos=0にいるとpos=xで工事中
        events.append(e)
    events.sort(key=attrgetter('start'))
    events = deque(events)

    D = (int(input()) for _ in range(Q))

    ans = [-1] * Q
    h = []
    for idx, d in enumerate(D):
        while events and events[0].start <= d:
            e = events.popleft()
            heappush(h, UC(pos=e.pos, end=e.end))

        while h and h[0].end <= d:
            heappop(h)

        if h:
            ans[idx] = h[0].pos

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 55980
#include<iostream>
#include<cmath>
#include<cstdlib>

int main()
{
    int N;
  	int	num=0;
    int i=0;
    long double x,y,z=0;
    long double Distance,D=0;

    std::cin >> N >> D;
    long double X[N],Y[N]={0};

    for(i=0; i<N; i++)
    {
        std::cin >> X[i] >> Y[i];
        x=X[i]*X[i];
        y=Y[i]*Y[i];
        z=x+y;
        Distance = std::sqrt(z);
        if( Distance <= D)
        {
            num++;
        }
        std::cout << std::endl;
    }
  
    std::cout << num;

    return 0;
}

Measured memory_bytes: 10076
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	int ans = a[0];
	// keisan
	while(a[n-2] != 0){
		int flag = 0;
		int s;
		for(int i=0;i<n;i++){
			if(flag){
				a[i] = a[i]%s;
			}else{
				if(a[i] != 0){
					s = a[i];
					flag = 1;
				}
			}
		}
		ans = s;
		sort(a,a+n);
	}
	// syutsuryoku
	cout << ans << endl;
}

Measured memory_bytes: 3904
def main():
    n = int(input())
    ls = sorted(list(map(int, input().split())))
    ans = 0

    for i, li in enumerate(ls):
        for j, lj in enumerate(ls[i+1:]):
            if li == lj:
                continue
            for lk in ls[i+j+2:]:
                if lj == lk:
                    continue

                if li + lj > lk:
                    ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include<stdio.h>
char str[1024],input[2048];

void print(void){
	int i,a,b;
	sscanf(input,"print %d %d",&a,&b);
	
	for(i=a;i<=b;i++){
		printf("%c",str[i]);
	}
	printf("\n");
}

void reverse(void){
	int i,a,b;
	char tmp;
	sscanf(input,"reverse %d %d",&a,&b);
	
	for(i=0;i<(b-a+1)/2;i++){
		tmp=str[a+i];
		str[a+i]=str[b-i];
		str[b-i]=tmp;
	}
}

void replace(void){
	int i,a,b;
	char tmp[1024];
	sscanf(input,"replace %d %d %s",&a,&b,&tmp);
	
	for(i=0;i<b-a+1;i++){
		str[a+i]=tmp[i];
	}
	
	
}

int main(){
	int i,num;
	
	fgets(str,sizeof str,stdin);
	
	fgets(input,sizeof input,stdin);
	sscanf(input,"%d",&num);
	
	for(i=0;i<num;i++){
		fgets(input,sizeof input,stdin);
		switch(input[2]){
			case 'p':
				replace();
			break;
				
			case 'v':
				reverse();
			break;
				
			case 'i':
				print();
			break;
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+13;
int a[maxn]; 
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			for(int z=j+1;z<=n;z++)
			{
				if(a[i]!=a[j]&&a[j]!=a[z]&&a[i]!=a[z])
				{
					if(a[i]+a[j]>a[z]&&a[i]+a[z]>a[j]&&a[z]+a[j]>a[i])
					{
						ans++;
					}
				}
			}
		}
	 }
	 printf("%d",ans); 
 } 

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

int main(){
    string s; cin>>s;

    int ans = 1000;

    for(int i=0; i<s.size()-2; i++){ 

        int com = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + ( s[i+2] - '0');

        int dif = abs(753-com);

        ans = min(ans,dif);
    
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
 
 int A,B;
 cin>>A>>B;
 if(A+B>9)
 {
   cout<<"error"<<endl;
 }
 else
 {
   cout<<A+B<<endl;
 }
 
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>

#define A strlen(a)
#define B strlen(b)
#define ANS strlen(ans)

using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    char x=0;
    for(int q = 0;q < n; q++){
        int f = 0;
        bool check[1000]={0};
        char a[1000]={0},b[1000]={0},ans[1000]={0};
        scanf("%s%s",a,b);
        reverse(a,a+A);
        reverse(b,b+B);

        int len1 = max(A,B);
        int len2 = min(A,B);

        (len1 == A) ? f=1 : f=2;

        if(len2 > 80 || len1 > 80){
            printf("overflow\n");
            continue;
        }

        for(int i = 0;i < len1; i++){
            if(a[i] == '0' && b[i] != '0'&&b[i] != 0){
                b[i] -= 48;
                ans[i] = b[i];
                //printf("o_o\n");
                continue;
            }
            if(a[i] != '0' && b[i] == '0'&&a[i] != 0){
                a[i] -= 48;
                ans[i] = a[i];
                continue;
            }
            if(a[i] == '0' && b[i] == '0'){
                ans[i] = '0';
                check[i] = 1;
                continue;
            }
            //printf("uu%d %d\n",A,B);
            if(i >= len2){
                //printf("('ω')v\n");
                //printf("f = %d\n",f);
                if(f == 1)ans[i] = a[i];
                if(f == 2)ans[i] = b[i];
                check[i] = 1;
                //printf("yoyo\n");
                continue;
            }
            a[i] -= 48;
            b[i] -= 48;
            x = a[i] + b[i];
            ans[i]= x;
        }
        for(int i = 0;i < ANS; i++){
            if(check[i] == 1){
                if(ans[i] >= 58){
                    if(ans[i] == 58){
                        ans[i] = '0';
                        ans[i+1]++;
                        continue;
                    }
                    else {
                        ans[i] -= 10;
                        ans[i+1]++;
                    }
                }
                //printf("yo-\n");
                continue;
            }
            else if(ans[i] >= 10){
                //printf("yo-yo-\n");
                if(ans[i] == 10){
                    ans[i] = '0';
                    ans[i+1]++;
                    continue;
                }
                else {
                    ans[i] = ans[i] - 10;
                    ans[i+1]++;
                }
            }
            ans[i] += 48;
        }

        reverse(ans,ans+ANS);

        (ANS > 80) ? printf("overflow\n") : printf("%s\n",ans);
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
  int N;
  cin >> N;
  int L[N];
  rep(i,N)
    cin >> L[i];
  
  int res = 0;
  for (int i = 0; i < N; i++){
    for (int j = i+1; j < N; j++){
      for (int k = j+1; k < N; k++){
        if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i])
          continue;
        if (abs(L[i]-L[j]) < L[k] && L[k] < L[i]+L[j])
          res++;
      }
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 3620
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<int> c(n - 1);
	vector<int> s(n - 1);
	vector<int> f(n - 1);

	for (int i = 0; i < n - 1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}

	int now = 0;

	for (int station = 0; station < n - 1; station++) {
		now = 0;
		for (int i = station; i < n - 1; i++) {
			if (now < s[i]) {
				now = s[i];
			}

			int ret = (now - s[i]) % f[i];
			if (ret == 0) {
				now += c[i];
			}
			else {
				now += c[i] + f[i] - ret;
			}

		}

		cout << now << endl;
	}

	
	

	cout << 0 << endl;
}

Measured memory_bytes: 256
import itertools


def main():
    n, m, x = map(int, input().split())
    lst = []
    for _ in range(n):
        lst.append(list(map(int, input().split())))

    flag1 = True
    max_lst = []
    for i in range(m):
        understanding = 0
        for j in range(n):
            understanding += lst[j][i+1]
        max_lst.append(understanding)

    for i in range(len(max_lst)):
        maximum = max_lst[i]
        if maximum < x:
            cost = -1
            flag1 = False
            break

    if flag1:
        number = 1
        cost_lst = []
        while number <= n:   ##一冊laからどんどん増やす
            n_lst = []
            for i in range(n):
                n_lst.append(i)
            choice = list(itertools.combinations(n_lst, number))
            combination_number = len(choice)
            choice_number = len(choice[0])

            for i in range(combination_number):

                cost1 = 0
                understanding_lst = [0] * m
                for j in range(choice_number):  ##一組終了
                    choiced_number = choice[i][j]
                    cost1 += lst[choiced_number][0]

                    for k in range(1, m + 1):
                        unstg = lst[choiced_number][k]
                        understanding_lst[k - 1] += unstg

                over_x = 0
                for l in range(m):
                    understanding = understanding_lst[l]
                    if understanding >= x:
                        over_x += 1

                if over_x == m:
                    cost_lst.append(cost1)

            number += 1

        cost = min(cost_lst)

    print(cost)


if __name__ == '__main__':
    main()

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

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

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

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 3e5 + 10;
int n, m, q, val[maxn], cst[maxn];

ll ans[maxn];

struct Querys {
  int u, x;
} Q[maxn];

ll dp[9][100010];
int mp[1 << 18 | 5];

vector <int> vec[maxn];

void dfs(int u, int dep) {
  if (u > n) return;
  if (dep < 9) {
    rep(i, 1, m) {
      dp[dep][i] = dep ? dp[dep - 1][i] : 0;
      if (cst[u] <= i) chkmax(dp[dep][i], (dep ? dp[dep - 1][i - cst[u]] : 0) + val[u]);
    }
    for (int i : vec[u]) {
      ans[i] = dp[dep][Q[i].x];
    }
    dfs(u << 1, dep + 1), dfs(u << 1 | 1, dep + 1);
    return;
  }
  dfs(u << 1, dep + 1), dfs(u << 1 | 1, dep + 1);
  if (vec[u].empty()) return;
  int tot = 0, anc[9];
  for (int v = u; v >= (1 << 9); v >>= 1) {
    anc[tot++] = v;
  }
  int all = (1 << tot) - 1;
  rep(S, 0, all) {
    int vals = 0, csts = 0;
    for (int x = S; x; x &= (x - 1)) {
      int id = mp[x & (-x)];
      vals += val[anc[id]], csts += cst[anc[id]];
    }
    for (int i : vec[u]) if (csts <= Q[i].x) {
      chkmax(ans[i], dp[8][Q[i].x - csts] + vals);
    }
  }
}

void solve() {
  m = 1e5;
  rep(i, 0, 18) mp[1 << i] = i;
  cin >> n;
  rep(i, 1, n) val[i] = read(), cst[i] = read();
  cin >> q;
  rep(i, 1, q) Q[i].u = read(), Q[i].x = read(), vec[Q[i].u].push_back(i);
  dfs(1, 0);
  rep(i, 1, q) printf("%lld\n", ans[i]);
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

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

int main() {
  int a, b, A, B;
  cin >> a >> b;
  A = a % 2;
  B = b % 2;
  if(A==0 || B==0)
    cout << "Even" << endl;
  if(A==1 && B==1)
    cout << "Odd" << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{

	
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		PrintWriter  out=new PrintWriter(System.out);
		int n=sc.nextInt(),k=sc.nextInt();
		long []a=new long [n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextLong();
		long ans=Long.MAX_VALUE;
		int idx=-1;
		for(int i=0;i<n;i++)
			if(a[i]>=0)
			{
				idx=i;
				break;
			}
		
		if(idx==-1)
		{
			ans=-a[n-k];
		}
		else
		{
			for(int i=idx;i+k-1<n;i++)
			{
				ans=Math.min(ans, a[i+k-1]);
			}
			for(int i=idx-1;i>=0;i--)
			{
				if(i+k-1<n)
				{
					long l=-a[i];
					long r=a[i+k-1];
					ans=Math.min(ans, Math.min(2*l+r, 2*r+l));
				}
			}
		}
		out.println(ans);
		
		
		out.close();
	}
	
	
	static class Scanner {
        StringTokenizer st;
        BufferedReader br;
 
        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }
 
        public Scanner(FileReader s) {
            br = new BufferedReader(s);
        }
 
        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
 
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
 
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
 
        public String nextLine() throws IOException {
            return br.readLine();
        }
        public boolean ready() throws IOException {return br.ready();}
        public double nextDouble() throws IOException {return Double.parseDouble(next());}
       
    }

}

Measured memory_bytes: 37772
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
//   ll n,w1,v,i,j,k,w;
    string s,t,ans;
    ll i,j;
    cin>>s;
    cin>>t;
    ll arr[s.size()+1][t.size()+1];
    for(i=0;i<s.size()+1;i++)
    {
        for(j=0;j<t.size()+1;j++)
        {
            arr[i][j]=0;
        }

    }

    for(i=1;i<s.size()+1;i++)
    {
        for(j=1;j<t.size()+1;j++)
        {
            if(s[i-1]==t[j-1])
            {
                arr[i][j]=arr[i-1][j-1]+1;
            }
            else
            {
                arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
            }
            
        }
    }

    ll length=arr[s.size()][t.size()];
    i=s.size();
    j=t.size();
    while(ans.size()!=length)
    {
        
        if(arr[i][j]!=max(arr[i][j-1],arr[i-1][j]))
        {
            ans.push_back(s[i-1]);
            i=i-1;
            j=j-1;
            
        }
        else if(arr[i][j]==max(arr[i][j-1],arr[i-1][j]))
        {
           (arr[i][j-1]>=arr[i-1][j])?j=j-1:i=i-1;
        }
    }
    for(i=ans.size()-1;i>=0;i--)
    {cout<<ans[i];}
    cout<<endl;

}

Measured memory_bytes: 74048
#include <algorithm>
#include <list>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#include <array>
#include <cstdio>
using std::cin;
using std::cout;
using std::endl;

int main(int argc, char* argv[])
{
  std::list<std::string> data;
  int n; 
  cin >> n;
  for(size_t i = 0 ; i < n; ++i )
  {
    std::string a;
    cin >>  a;
    data.emplace_back(a);
  }
  data.sort();
  data.unique();
  cout << data.size() << endl;

}


Measured memory_bytes: 16120
my $N = <>;
my @A = split " ", <>;
my $result = 0;
my $flag;
while (1) {
    for (@A) {
        if ($_ % 2) {
            $flag = 1;
            last;
        }
    }
    last if $flag;
    $result++;
    for (1..$N) {
        $A[$_] = $A[$_] / 2;
    }
}
print $result;


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll n, ans;

int main() {
	fastio; cin >> n;
	FOR(a, 1, n) {
		ans += (n-1)/a;
	}
	cout << ans;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <stdio.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define pf push_fron
#define INF 1000000000
typedef long long ll;

vector<pair<int, int>> p[100010];
bool flag[100010];
int d[100010];
int n, m;

void dfs(int node, int t) {
	if (flag[node]) {
		if (d[node] != t) {
			cout << "No" << endl;
			exit(0);
		}
		return;
	}
	flag[node] = true;
	d[node] = t;
	for (int i = 0; i < p[node].size(); i++)dfs(p[node][i].first, t + p[node][i].second);
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int peo,r,d;
		cin >> peo >> r >> d;
		peo--; r--;
		p[peo].pb(mp(r,d));
		p[r].pb(mp(peo, -d));
	}
	
	for (int i = 0; i < n; i++) {
		if (!flag[i])dfs(i, 0);
	}
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 12032
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	vector<LL> a, b;
	LL n, k;
	cin >> n >> k;
	for (LL i = 0; i < n; ++i) {
		LL x;
		cin >> x;
		if (x >= 0) {
			a.push_back(x);
		} else {
			b.push_back(-x);
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	LL ans = a.size() >= k ? a[k - 1] : (1LL << 60);
	if (b.size() >= k) {
		ans = min(ans, b[k - 1]);
	}
	for (LL i = 1; i < k; ++i) {
		LL j = k - i;
		if (a.size() >= i && b.size() >= j) {
			ans = min(ans, a[i - 1] * 2 + b[j - 1]);
			ans = min(ans, a[i - 1] + b[j - 1] * 2);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1656
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n;
int ans=0,sum[100005];
struct que
{
	int l,r;
}a[100005];
bool cmp(que a,que b)
{
	return a.r<b.r;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].l,&a[i].r);
	sort(a+1,a+n+1,cmp);
	int minr=1e9,maxl=0;
	for(int i=1;i<=n;i++)
	{
		minr=min(minr,a[i].r);maxl=max(maxl,a[i].l);
		sum[i]=max(minr-maxl+1,0);
	}
	minr=1e9,maxl=0;
	for(int i=n;i>=1;i--)
	{
		minr=min(minr,a[i].r);maxl=max(maxl,a[i].l);
		ans=max(ans,max(minr-maxl+1,0)+sum[i-1]);
	}
	for(int i=1;i<=n;i++) ans=max(ans,max(minr-maxl+1,0)+a[i].r-a[i].l+1);
	printf("%d\n",ans);
}

Measured memory_bytes: 4892
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long double ld;
#define s second
#define f first

int main()
{	
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    {	ld a,b;
    	cin>>a>>b;
    	cout<<(lli)(a*b)<<endl;
 
    }
	return 0;
}

Measured memory_bytes: 3744
<?php
fscanf(STDIN,"%d",$n);
fscanf(STDIN,"%s",$s);
$count_rgb = array();
for($i=0;$i<$n;$i++){
  $count_rgb[$s[$i]]++;
}

$result = $count_rgb['R']*$count_rgb['G']*$count_rgb['B'];
$bad_condition_c = 0;
for($i=0;$i<$n;$i++){
  for($j=$i;$j<$n;$j++){
    $diff = $j-$i;
    $k = $diff+$j;
    if(isset($s[$k])){
      if($s[$i]!=$s[$j] && $s[$j]!=$s[$k] && $s[$k]!=$s[$i]){
          $bad_condition_c++;
      }
    }
  }
}
//echo $result."\n";
echo ($result-$bad_condition_c);

Measured memory_bytes: 16056
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int c = sc.NextInt();
        int k = sc.NextInt();
        int[] t = new int[n];
        for (int i = 0; i < n; i++)
        {
            t[i] = sc.NextInt();
        }

        t = t.OrderBy(i => i).ToArray();

        int answer = 0;

        int limit = 0;
        int count = 0;
        for (int i = 0; i < n; i++)
        {
            if (limit == 0 || t[i] > limit)
            {
                limit = t[i] + k;
                answer++;
                count = 1;
            }
            else
            {
                count++;
            }
            if (count == c)
            {
                limit = 0;
                count = 0;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 20304
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
			
void solve() {
	ll num, k, d;
	cin >> num >> k >> d;
	num = abs(num);
	ll t = num;	
	num = num - d * min(num/ d, k);
	k = k - min(t / d, k);
	if(num <= abs(num - d)){
	if(k % 2 != 0) {
		cout << abs(num - d) << endl;
		}
		else {
			cout << num << endl;
			}
		}
		else {
			k--;
			num = num - d;
			if(k % 2 != 0) {
				cout << abs(num + d) << endl;
				}
				else {
					cout << abs(num) << endl;	
					}
			}
}


	

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}






Measured memory_bytes: 3684
n = int(input())
#n,m = map(int,input().split())
lst1 = list(map(int,input().split()))

dic1 = dict()

for i in lst1:
    if i in dic1:
        dic1[i] += 1
    else:
        dic1[i] = 1

ans = 0

for i in dic1:
    if i > dic1[i]:
        ans += dic1[i]
    elif i < dic1[i]:
        ans += dic1[i] - i

print(ans)


Measured memory_bytes: 67112
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mod = 10**9+7

def main():
	n,k = MI()
	dp=[0]*(k+1)
	ans=0
	def g(x, n, mod):
		if n == 0:
			return 1
		K = 1
		while n > 1:
			if n % 2 != 0:
				K *= x
			x *= x%mod
			K %= mod
			n //= 2
		return K * x

	for i in range(k,0,-1):
		dp[i]=g(k//i,n,mod)
		for j in range(i*2,k+1,i):
			dp[i]-=dp[j]
			dp[i]%=mod
		dp[i]=(dp[i]%mod+mod)%mod
		ans+=i*dp[i]%mod
	print(ans%mod)
if __name__ == '__main__':
	main()

Measured memory_bytes: 11180
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define rep(i,x) for(int i=0;i<x;i++)
using namespace std;

int main(){
    int n; cin >> n;
    vector<pair<int, int>> cors;
    vector<int> order(n);
    rep(i, n){
        int x, y; cin >> x >> y;
        cors.push_back({x, y});
        order[i] = i;
    }
    double sumdist = 0;
    do{
        double alldist = 0;
        rep(i, n - 1){
            double dx = cors[order[i+1]].first - cors[order[i]].first;
            double dy = cors[order[i+1]].second - cors[order[i]].second;
            double dist = sqrt(dx * dx + dy * dy);
            alldist += dist;
        }
        sumdist += alldist;
    }while(next_permutation(order.begin(), order.end()));
    int factN = 1;
    rep(i, n) factN *= i + 1;
    cout << fixed << setprecision(10) << sumdist / factN << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;


int main(void){
    string S;
    cin >> S;
    int cnt = 0;
    int ans = 0;
    for(int i=0; i<3; i++){
        if(S[i]=='R'){
            cnt++;
        }else{
            cnt = 0;
        }
        ans = ans<cnt? cnt: ans;
    }
    
    cout << ans << endl;
}


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

int main(void){
    string s;
    
    cin>>s;
    char t=s[0];
    ll cnt=0;
    for(ll i=1;i<s.length();++i){
        if(t!=s[i]){
            cnt++;
            t=s[i];
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp36 {
    class Program {
        static void Main(string[] args) {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C = int.Parse(Console.ReadLine());
            int D = int.Parse(Console.ReadLine());

            Console.WriteLine(Math.Min(A, B) + Math.Min(C, D));
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





















int main(){
    ll n, m;
    scanf("%lld %lld", &n, &m);
    ll a[100000];
    for(int i = 0; i < n; i++){
        scanf("%lld", &a[i]);
    }
    sort(a, a + n);
    ll down = 0, up = INF;
    while(up - down > 1){
        ll mid = (up + down) / 2;
        ll cnt = 0;
        for(int i = 0; i < n; i++){
            ll idx = lower_bound(a, a + n, mid - a[i]) - a;
            cnt += n - idx;
        }
        ((cnt >= m)? down : up) = mid;
    }
    ll aa[100001] = {};
    for(int i = 0; i < n; i++){
        aa[i + 1] = a[i] + aa[i];
    }
    ll ans = 0, cnt = 0;
    for(int i = 0; i < n; i++){
        ll idx = lower_bound(a, a + n, down - a[i]) - a;
        ans += aa[n] - aa[idx] + (n - idx) * a[i];
        cnt += n - idx;
    }
    printf("%lld\n", ans - (cnt - m) * down);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int dp[100100];
int n;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	memset(dp,63,sizeof(dp));
	dp[n]=0;
	for(int i=n;i>0;i--){
		for(int j=6;j<=i;j*=6){
			dp[i-j]=min(dp[i-j],dp[i]+1);
		}
		for(int j=9;j<=i;j*=9){
			dp[i-j]=min(dp[i-j],dp[i]+1);
		}
	}
	int res=1e9;
	for(int i=0;i<=n;i++){
		res=min(res,dp[i]+i);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 640