akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;

#define debug(args...) \
cout << "#" << __LINE__ << ": "; \
__dbg(split(#args, ',').begin(), args);
vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}
template<typename T, typename... Args>
inline string to_str(T x) {
	stringstream ss; ss << "[";
	for (auto it = x.begin(); it != x.end(); it++) {
		if (it != x.begin()) ss << " ";
		ss << (*it);
	}
	ss << "]";
	return ss.str();
}
template<typename T, typename... Args>
inline string to_str(stack<T> x) {
	stringstream ss; ss << "[";
	bool first = 1;
	while (!x.empty()) {
		if (!first)
			ss << " ";
		ss << x.top();
		x.pop();
		first = 0;
	}
	ss << "]";
	return ss.str();
}
template<typename T> inline void __dbg_var(vector<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(list<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(set<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(unordered_set<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(stack<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(T val) { cout << val; }
inline void __dbg(vector<string>::iterator it) { cout << endl; }
template<typename T, typename... Args>
inline void __dbg(vector<string>::iterator it, T a, Args... args) {
	cout << it->substr((*it)[0] == ' ', it->length()) << "=";
	__dbg_var(a);
	cout << " ";
	__dbg(++it, args...);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
			
			
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC\n";
	else cout << "ABC\n";
	return 0;
}


Measured memory_bytes: 3648
x=int(input())

def enum_div(n):
    ir=int(n**(0.5))+1
#    ret=[]
    ret=set()
    for i in range(1,ir):
        if n%i == 0:
            ret.add(i)
#            ret.append(i)
            if (i!= 1) & (i*i != n):
#                ret.append(n//i)
                ret.add(n//i)
    return ret

ret=enum_div(x)

y=20000
for ai in range(-y,y):
    yn=""
    for r in ret:
        bi=ai-r
        if ai**5-bi**5==x:
            yn="YES"
            break
        bi=ai+r
        if ai**5-bi**5==x:
            yn="YES"
            break
    if yn=="YES":
        break

if yn=="YES":
    print(ai,bi)

Measured memory_bytes: 9460
import sys

n, blue, red = map(int, input().split())
ball = blue + red

if blue == 0:
    print(0)
    sys.exit()
if n <= blue or red == 0:
    print(n)
    sys.exit()
if n <= ball:
    print(blue)
    sys.exit()

ans = n // ball
additional = n % ball

if additional == 0:
    print(ans * blue)
elif additional <= blue:
    print(ans * blue + additional)
else:
    print((ans + 1) * blue)

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

template<class T>
class Union_Find {
private:
  T n;
  vector<T> parent;
public:
  Union_Find(T v){
    n=v;
    parent.resize(n,-1);
  }
  T root(T v){
    if(parent[v]<0)return v;
    return parent[v]=root(parent[v]);
  }
  T size(T v){
    return -parent[root(v)];
  }
  bool connect(T a,T b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(size(a)<size(b)) swap(a,b);
    parent[a]+=parent[b];
    parent[b]=a;
    return true;
  }
  bool same(T a,T b){
    return root(a)==root(b);
  }
  T operator[](T a){
    return root(a);
  }
  bool operator()(T a,T b){
    return connect(a,b);
  }
};

int main(){

  int n;
  cin>>n;
  auto a = vec<ll>(n,n);
  cin>>a;

  auto b = a;
  bool is_shortest = true;
  rep(k,n)rep(i,n)rep(j,n){
    if(chmin(a[i][j],a[i][k]+a[k][j]))is_shortest=false;
  }
  if(!is_shortest){
    cout<<(-1)<<endl;
    return 0;
  }

  struct edge{
    ll f,t,c;
    edge(){}
    edge(ll f,ll t,ll c):f(f),t(t),c(c){}
    bool operator< (edge const& rhs){
      return c < rhs.c;
    }
  };
  vector<edge> E;
  E.reserve(n*n);
  rep(i,n)rep(j,n){
    if(i<=j)continue;
    E.emplace_back(i,j,a[i][j]);
  }
  sort(E.begin(),E.end());

  ll ans = 0;
  auto d = _vec<ll>(n,n,INF);
  //rep(i,n)d[i][i]=0;
  for(auto e:E){
    if(chmin(d[e.f][e.t],e.c)){
      d[e.t][e.f] = e.c;
      ans += e.c;
      rep(i,n)rep(j,n){
        chmin(d[i][j],d[i][e.f]+d[e.f][j]);
        chmin(d[i][j],d[i][e.t]+d[e.t][j]);
      }
      rep(i,n)rep(j,n){
        chmin(d[i][j],d[i][e.f]+d[e.f][j]);
        chmin(d[i][j],d[i][e.t]+d[e.t][j]);
      }
      rep(i,n)rep(j,n){
        chmin(d[i][j],d[i][e.f]+d[e.f][j]);
        chmin(d[i][j],d[i][e.t]+d[e.t][j]);
      }
    }
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 3456
A, B = map(int, input().split())
money = 0
if A==1 and B ==1:
    print("1000000")
elif A<4 and B > 3:
    money = 100000 * (4-A)
    print(money)
elif A>3 and B < 4:
    money = 100000 * (4-B)
    print(money)
elif A <4 and B <4:
    money = 100000 * (4-A) + 100000 * (4-B)
    print(money)
else:
    print("0")

Measured memory_bytes: 3064
#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
v=get_i
odd={}
even={}
N.times do|i|
    if (i+1).odd?
      odd[v[i]]=0 if odd[v[i]].nil?
      odd[v[i]]+=1
    else
      even[v[i]]=0 if even[v[i]].nil?
      even[v[i]]+=1
    end
end
odd=odd.sort{|x,y| y[1]<=>x[1]}
even=even.sort{|x,y| y[1]<=>x[1]}
if odd[0][0]!=even[0][0]
    puts N-odd[0][1]-even[0][1]
else
    if odd.size==1 and even.size==1
        puts N/2
    elsif even[0][1]+odd[1][1]>odd[0][1]+even[1][1]
        puts N-even[0][1]-odd[1][1]
    else
        puts N-odd[0][1]-even[1][1]
    end
end

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int K;
int N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K;
	
	if(K==1) {
		cout<<1<<endl;
		cout<<1<<endl;
		return;
	}
	
	int step=((K+3)/4)*4;
	N=step/2;
	cout<<N<<endl;
	FOR(y,N) {
		FOR(x,N) {
			r=(x+y)%N;
			if(y%2) r+=N;
			if(r>=K) r-=N;
			cout<<(r+1)<<" ";
		}
		cout<<endl;
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1152
($H,$W,$D)=glob<>;
for$y(1..$H){
	@_[glob<>]=map[$y,$_],1..$W
}
for(1..9e4){
	$s[$_+$D]=
		$s[$_]+
		abs((@b=@{$_[$_+$D]})[1]-(@a=@{$_[$_]})[1])+
		abs"@b"-"@a"
}
<>;/ /,print$s[$']-$s[$`],$/for<>


Measured memory_bytes: 35072
// I can't tell you what it really is,
// I can only tell you what it feels like.
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define F first
#define S second
#define sz(x) (int)x.size() - 1
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define fo(i, n)   for (int i = 1; i <= n; ++i)
#define all(v)  v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define E cout << '\n'

const int mod = 1e9 + 7;
const int N = 3e5 + 5;

int h[27][N], n;
bool check(int mid) {
    rep(i, mid, n) {
        int a = h[0][i] - h[0][i - mid];
        int c = h[2][i] - h[2][i - mid];
        int g = h[6][i] - h[6][i - mid];
        int t = h['T' - 'A'][i] - h['T' - 'A'][i - mid];
        if(a + c + g + t == mid)
            return true;
    }
    return false;
}
inline void solve() {
     char c, ch;
     cin >> c;
     switch(c) {
         case 'A':
             ch = 'T';
             break;
            
         case 'T':
             ch = 'A';
             break;
             
         case 'C':
             ch = 'G';
             break;
             
         case 'G':
             ch = 'C';
             break;
     }
    cout << ch;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t; while(t--)
                solve();
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def run_length(s):
    ans=[]
    if len(s)==1:
        ans.append((s,1))
        return ans
    s_pre=s[0]
    cunt=1
    for i,ss in enumerate(s[1:],1):
        if ss==s_pre:
            cunt+=1
        else:
            ans.append((s_pre,cunt))
            cunt=1
            s_pre=ss
    ans.append((s_pre,cunt))
    return ans

def main():
    s=input()
    k=int(input())
    s_lis=run_length(s)
    ans=0    
    if len(s_lis)==1:
        print(k*s_lis[0][1]//2)
    else:
        for tup in s_lis:
            ans+=tup[1]//2  
        if s_lis[0][0]==s_lis[-1][0]:
            a=s_lis[0][1]
            b=s_lis[-1][1]
            print(ans*k-(a//2+b//2-(a+b)//2)*(k-1))
        else:
            print(ans*k)


if __name__=='__main__':
    main()

Measured memory_bytes: 38384
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

x = inp()
if x == 1:
    x = 0
else:
    x = 1
print(x)

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


def solve(A: int, B: int, C: int, K: int):
    if (A >= K):
        print(K)
    elif (A+B >= K):
        print(A)
    else:
        print(A - (K - (A+B)))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9208
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define int ll
using pint = pair<int,int>;
using Graph = vector<vector<int>>;
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 1e10; //10^10
const double PI = acos(-1.0L);
/*mod逆元*/long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
template< typename T >T mod_pow(T x, T n, T p=MOD) {T ret = 1;while(n > 0) {if(n & 1) (ret *= x) %= p;(x *= x) %= p;n >>= 1;}return ret;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------ライブラリとか----------------

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

    int n,m; cin >> n >> m;
    int ans = 0;
    if(n<=m/2){
        ans += n;
        m -= n*2; n = 0;
        ans += m/4;
    }else{
        ans += m/2;
        n -= m/2; m= 0;
    }
    out(ans);

    return 0;
}

Measured memory_bytes: 256
x = gets.to_i
kyu = nil

case x
when 400..599
  kyu = 8
when 600..799
  kyu = 7
when 800..999
  kyu = 6
when 1000..1199
  kyu = 5
when 1200..1399
  kyu = 4
when 1400..1599
  kyu = 3
when 1600..1799
  kyu = 2
when 1800..1999
  kyu = 1
end

puts kyu

Measured memory_bytes: 14384
#include <stdio.h>
#include <iostream>
#include <cmath>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    long ans = 1000000000005;
    for (long a = 1; a <= sqrt(n); ++a) {
        long b = n / a;
        if (a * b == n) {
            long tmp = a + b - 2;
            if (ans > tmp) {
                ans = tmp;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
h = list(li())
hmax = 0

ans = 0
for hi in h:
    if hi >= hmax:
        ans += 1
        hmax = hi
print(ans)

Measured memory_bytes: 3064
//g++ -std=gnu++14 a.cpp
//#include <bits/stdc++.h>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){

  int x,N;
  cin >> x >> N;

  int p[N],p_count[102];
  rep(i,N)cin >> p[i];
  rep(i,102)p_count[i]=1;
  rep(i,N)p_count[p[i]]=0;

  ll ans = INF;
  ll d = INF;
  rep(i,102){
    if(p_count[i]){
      if(d > abs(x-i)){
        ans = i;
        d = abs(x-i);
      }
    }
  }

  cout << ans << endl;



}


Measured memory_bytes: 3612
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		if(s.equals("Sunny")) {
			System.out.println("Cloudy");
		}
		
		if(s.equals("Cloudy")) {
			System.out.println("Rainy");
		}
		

		if(s.equals("Rainy")) {
			System.out.println("Sunny");
		}


		sc.close();
	}
}



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

int min(int a, int b) {
    if(a <= b) {
        return a;
    }
    else {
        return b;
    }
}

int main(void){
    int A, B, C, D;
    scanf("%d %d %d %d", &A, &B, &C, &D);
    int s1, s2, e1, e2;

    if(A < C) {
        s1 = 0;
        s2 = C - A;
        e1 = B - A;
        e2 = D - A;
    }
    else {
        s1 = 0;
        s2 = A - C;
        e1 = D - C;
        e2 = B - C;
    }

    if(e1 <= s2) {
        printf("0\n");
        return 0;
    }
    printf("%d\n", min(e1, e2) - s2);
    return 0;
}

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

vector<vector<pair<int,int>>> G(100010);
vector<long long> cost(100010,0);
vector<bool> used(100010);

void dfs(int n){
  used[n]=true;
  for (int i=0;i<G[n].size();i++){
    pair<int,int> e=G[n][i];
    if (!used[e.first]){
      cost[e.first]=cost[n]+(long long)e.second;
      dfs(e.first);
    }
  }
}

int main() {
  int N;
  cin >> N;
  for (int i=0;i<N-1;i++){
    int a,b,c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[b].push_back(make_pair(a,c));
    G[a].push_back(make_pair(b,c));
  }
  int Q,K;
  cin >> Q >> K;
  dfs(K-1);
  for (int i=0;i<Q;i++){
    int x,y;
    cin >> x >> y;
    cout << cost[x-1]+cost[y-1] << endl;
  }
}

Measured memory_bytes: 12800
#include<iostream>
#include<stdio.h>
using namespace std;
int main() {
	int a, c;
	char o;
	while (1) {
		scanf("%d %c %d",&a,&o,&c);
		if (o == '?') break;
		else if (o == '+') {
			cout << a + c << endl;
		}
		else if (o == '-') {
			cout << a - c << endl;
		}
		else if (o == '*') {
			cout << a * c << endl;
		}
		else if (o == '/') {
			printf("%d\n", a / c);
		}
		else
			return 0;
	}
	return 0;
}

Measured memory_bytes: 3200
// AOJ 2526 Pie Chart is as easy as pie.
// 2018.3.5 bal4u

#include <stdio.h>
#include <math.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

#define EPS 1e-8
#define PI 3.1415926535897932384626433832795

typedef struct { double x, y; } PP;
typedef struct { PP s, e; } SEG;

PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
PP vmul(PP p1, PP p2) { PP r; r.x = p1.x*p2.x-p1.y*p2.y, r.y = p1.x*p2.y+p1.y*p2.x; return r; }
double cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }
double dot(PP a, PP b) { return a.x * b.x + a.y * b.y; }
double norm(PP a) { return a.x * a.x + a.y * a.y; }
int ccw(PP p0, PP p1, PP p2) { PP a, b;	double t;
	a = vsub(p1, p0), b = vsub(p2, p0), t = cross(a, b);
	if (t >  EPS) return 1;	if (t < -EPS) return -1;
	if (dot(a, b) < -EPS) return 2;	if (norm(a) < norm(b)) return -2;
	return 0;
}

int main()
{
	int r, n, p, i;
	double as, bs, sa, ta, prea = PI/2;
	PP s, t, center, prep = {0,100}, zero = {0,0};

	r = in(), center.x = in(), center.y = in(), n = in();
	for (i = 0; i < n; i++) {
		if (i) putchar(' ');
		p = in();

		double cs = p/100.0 * r*r*PI;
		s = prep;
		sa = PI/2, ta = sa - p/50.0 * PI;
		t.x = cos(ta-sa), t.y = sin(ta-sa);
		prep = t = vmul(s, t);
		prea = ta;

		bs = 0.5 * fabs(cross(s, t));
		as = 0.5 * fabs(cross(vsub(s, center), vsub(t, center)));
		if (ccw(s , t, zero) == 1) bs = -bs;
		if (ccw(s, t, center) == 1) as = -as;
	    printf("%d", (int)(100* fabs(cs - bs + as) / cs));
	}
	putchar('\n');
    return 0;
}



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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineIntSpilit();

            Console.WriteLine((n[0] - 1) * (n[1] - 1));
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
          

int main(){
    int n=100009;
    vector<char> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (is_prime[i] && (long long)i * i <= n) {
            for (int j = i * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
    vector<int> temp;
    for(int i=2;i<=n;i++){
        if(is_prime[i])
            temp.push_back(i);
    }
    //for(int i=0;i<30;i++)
    //    cout<<temp[i]<<" ";
    int x;
    cin>>x;
    auto upper1 = upper_bound(temp.begin(), temp.end(), x-1) - temp.begin();
    cout<<temp[upper1];
    return 0;
}


Measured memory_bytes: 436
a = []
for i in range(3):
    a.append(list(input()))
x = ord(a[0][0])-97
del a[0][0]
while True:
    if len(a[x])==0:
        print(chr(x+65))
        break
    else:
        y = x
        x = ord(a[x][0])-97
        del a[y][0]

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
#define ALL(x) (x).begin(), (x).end()

int main()
{
	int N, K;
	cin >> N >> K;
	vector<ll> A(N + 1, 0);
	for (int i = 1; i <= N; i++)
		cin >> A[i];

	vector<ll> out(N + 1);

	if (K <= 100) {
		for (int k = 0; k < K; k++)
		{
			for (int i = 0; i <= N; i++)
				out[i] = 0;

			for (int i = 1; i <= N; i++)
			{
				if (i - A[i] >= 0)
					out[i - A[i]]++;
				else
					out[0]++;

				if (i + A[i] + 1 <= N)
					out[i + A[i] + 1]--;
			}

			for (int i = 1; i <= N; i++)
			{
				out[i] += out[i - 1];
				A[i] = out[i];
			}
		}

		for (int i = 1; i <= N; i++)
			cout << out[i] << ((i == N) ? '\n' : ' ');
	} else {
		for (int i = 1; i <= N; i++)
			cout << N << ((i == N) ? '\n' : ' ');
	}
}

Measured memory_bytes: 6404
N = int(input())
A = list(map(int, input().split()))
print(' '.join([str(a) for a in A]))
for i in range(1, N):
    v = A[i]
    j = i - 1
    while (j>=0) and (A[j]>v):
        A[j+1] = A[j]
        j -= 1                            
    A[j+1] = v
    print(' '.join([str(a) for a in A]))


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

const ll MAX = 1000001;
const ll MOD = 1000000007;

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

// コンビネーションのテーブルを作る前処理
// ll COMとワンセット
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
    COMinit();
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    if (k != 1)
        ans++;
    for (ll i = 1; i < n; i++) {
        if (i > k)
            break;
        ans = (ans + COM(n, i)*COM(n-1, n-i-1)%MOD) % MOD;
    }
    cout << ans;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
int a[1000],ans;

int main(){
	string s;
	cin>>s;
	int len=s.size();
	
	for(int i=0;i<len;i++)
	a[i]=s[i];
	
	for(int i=0;i<len;i++){
		if(a[i]!=a[len-i-1])
		ans++;
	}
	
	cout<<ans/2;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
template <class T> void corner(bool flg, T hoge) {
    if (flg) {
        cout << hoge << endl;
        exit(0);
    }
}
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n >> m;
    map<ll, ll> M;
    inputv(A, n);

    vl X;
    X.push_back(0);

    rep(i, n) {
        X.push_back(X.back() + A[i]);
    }

    rep(i, n+1) {
        M[X[i] % m]++;
    }

    for (auto ite = M.begin(); ite != M.end(); ite++) {
        ans += ((*ite).second) * ((*ite).second - 1) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5748
import java.util.*;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args){

		// 値取得
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> nums  = new ArrayList<>();
		while(sc.hasNext()){
			nums.add(sc.nextInt());

		}
		int kilo1 = 0;
		int kilo2 = 0;
		int kilo3 = 0;

		// 最短の飛行時間を計算する
		// それぞれのパーターンで時間の和を計算して最少を求める
		kilo1 = nums.get(0) + nums.get(1);
		kilo2 = nums.get(0) + nums.get(2);
		kilo3 = nums.get(1) + nums.get(2);
		if(kilo1 <= kilo2 && kilo1 <= kilo3){

			System.out.println(kilo1);
		}else if(kilo2 <= kilo1 && kilo2 <= kilo3){

			System.out.println(kilo2);				
		}else{

			System.out.println(kilo3);

		}
	}

}

Measured memory_bytes: 22728
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  long long K=0;
  int M=0;
  long long H=0;
  cin>>S;
  for(int X=0;X<S.size();X++){
    if(S[X]=='W'){
      K+=X;
      H+=M;
      M++;
    }
  }
  cout<<K-H<<endl;
}

Measured memory_bytes: 3712
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int N; cin>> N;
    set<string> s;

    for (int i = 0; i < N; i++) {
        string str; cin >> str;
        s.insert(str);
    }

    cout << s.size() << endl;
}


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

Measured memory_bytes: 19208
#include <iostream>

using namespace std;

int main(){
	int n,h,w;
	cin >> n >> h >> w;
	int cnt = 0;
	for (int i = 0;i < n;i++) {
		int t1,t2;
		cin >> t1 >> t2;
		if(t1 >= h && t2 >= w)
			cnt++;
	}
	cout << cnt << endl; 

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())



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


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

  reverse(s.begin(),s.end());
  reverse(t.begin(),t.end());
  bool can = false;

  rep(i,s.size()-t.size()+1){
    can = true;
    rep(j,t.size()){
      if(s[i+j]==t[j] || s[i+j]=='?'){
        continue;
      }else{
        can = false;
        break;
      }
    }
    if(can){
      rep(j,t.size()){
        s[i+j] = t[j];
      }
      break;
    }
  }
  reverse(s.begin(),s.end());
  replace(s.begin(),s.end(),'?','a');
  if(can) cout << s << endl;
  else cout << "UNRESTORABLE" << endl;

}

















//


Measured memory_bytes: 256
#if defined(LOCAL)
#define PROBLEM_NAME "b"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define C(x, ...) ;
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

void solve(istream& cin, ostream& cout) {
  l n; cin >> n;
  vl a(n), b(n);
  F(i, 0, n) cin >> a[i];
  F(i, 0, n) cin >> b[i];
  vl s(n);
  l answer = 0;
  F(k, 0, 29) {
    l a1 = 0, b1 = 0;
    F(i, 0, n) a1 += (a[i] >> k) & 1;
    F(i, 0, n) b1 += (b[i] >> k) & 1;
    l t = a1 * (n - b1) + b1 * (n - a1);
    l q = l(1) << k;
    l m = q - 1;
    for (l i : b) {
      auto p = lower_bound(all(s), q - (i & m));
      t += distance(p, s.end());
    }
    answer += (t % 2) << k;
    m = (l(1) << (k + 1)) - 1;
    F(i, 0, n) s[i] = a[i] & m;
    sort(all(s));
  }
  cout << answer << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 4992
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {

		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		LinkedList<Integer> b = new LinkedList<>();
		boolean head = true;

		for (int i = 0; i < N; i++) {
			int ai = sc.nextInt();
			if(head) {
				b.add(ai);
			}else {
				b.addFirst(ai);
			}
			head = !head;
		}
		
		Integer [] arr = b.toArray(new Integer[b.size()]);
		if(head) {
			for(int i=0; i<N-1; i++) {
				System.out.print(arr[i] + " ");
			}
			System.out.println(arr[N-1]);
		}else {
			for (int i=N-1; i>0; i--) {
				System.out.print(arr[i]+" ");
			}
			System.out.println(arr[0]);
		}
		sc.close();
	}

}


Measured memory_bytes: 99804
#include <stdio.h>

#define SIZE 100

int main(void) {
  int N = 0;
  int M = 0;

  int paper[SIZE] = {0};
  int target[SIZE] = {0};
  int score[SIZE] = {0};

  scanf("%d", &N);
  scanf("%d", &M);

  for (int i = 0; i < M ; i++) {
    scanf("%d", &target[i]);
    target[i]--;
  }

  for (int i = 0; i < M; i++) {
    int t = target[i];
    int X = 0;
    
    for(int j = 0; j < N; j++) {
      scanf("%d", &paper[j]);
      paper[j]--;

      if (t == paper[j]) {
	score[j]++;
      } else {
	X++;
      }
    }

    score[t] += X;
  }

  for (int i = 0; i < N; i++) {
    printf("%d\n", score[i]);
  }
  
  return 0;
}

Measured memory_bytes: 1024
X = int(input())

more_100 = X/100
under_100 = X%100
X2 = int(under_100 / 5)
X3 = under_100 % 5
if X3 != 0 and X2 + 1 <= more_100:
  print(1)
elif X3 == 0 and X2 <= more_100:
  print(1)
else:
  print(0)

Measured memory_bytes: 3060
N = int(input())
L = list(map(int, input().split()))

MinatoYukina = [0]*100003

for i in range (0, N):
	MinatoYukina[L[i]]+=1
	MinatoYukina[L[i]+1]+=1
	MinatoYukina[L[i]+2]+=1

print(max(MinatoYukina))

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

#define ll long long 

int main() {
    ios::sync_with_stdio(0); 

    string s; cin >> s;
    if (s[2] == s[3] and s[4] == s[5]) cout << "Yes";
    else cout << "No";

    cout << endl;

    return 0; 
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  string t; cin >> t;
  int n = s.length();
  for(int i = 0; i < n; ++i){
    if(s[i] != t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" <<endl;
}

Measured memory_bytes: 3596
#include <iostream>
 using namespace std;
 long long N, A[87], CurrentMoney = 1000;
 int main() {
 cin >> N;
 for (int i = 1; i <= N; i++) cin >> A[i];
 for (int i = 1; i <= N - 1; i++) {
 long long Stocks = 0;
 if (A[i] < A[i + 1]) Stocks = CurrentMoney / A[i];
 CurrentMoney += (A[i + 1] - A[i]) * Stocks;
 }
 cout << CurrentMoney << endl;
 }

Measured memory_bytes: 3580
import math
import copy
 
 
 
 
def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:
 
            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l
 
a=nCast(input().split());

b=nCast(inputArr1(a[0]))


def bkey(n):
    return n[0]
 
def func():
    b.sort(key=bkey)
    sum=0
    count=0
    for idx in range(0,len(b)):

        if count+b[idx][1]<a[1]:
            count+=b[idx][1]
            sum+=b[idx][0]*b[idx][1]
        else:
            sum+=b[idx][0]*(a[1]-count)
            return sum
    return sum
    
print(func()) 

Measured memory_bytes: 35872
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N, C;
    cin >> N >> C;
    vector<ll> s(N), t(N), c(N);
    loop(i, N)
    {
        cin >> s[i] >> t[i] >> c[i];
        c[i]--;
    }
    vector<vector<ll>> record(C, vector<ll>(100010));
    loop(i, N)
    {
        Loop(j, s[i], t[i] + 1) record[c[i]][j] = 1;
    }
    ll ans = 0;
    loop(i, 100010)
    {
        ll count = 0;
        loop(j, C) if (record[j][i]) count++;
        ans = max(ans, count);
    }
    putout(ans);
    return 0;
}


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

using pii = pair<int, int>;

int main()
{
    int N, C; cin >> N >> C;
    vector<pair<int, pii>> cst(N);
    for (auto& e : cst) {
        cin >> e.second.first >> e.second.second >> e.first;
    }
    sort(cst.begin(), cst.end());

    vector<int> imos(2 * 1E5 + 1);
    for (int i = 0; i < N; i++) {
        int& c = cst[i].first;
        int& s = cst[i].second.first;
        int& t = cst[i].second.second;
        if (i != 0 && c == cst[i-1].first
            && s == cst[i-1].second.second) {
            imos[s*2] += 1;
        } else {
            imos[s*2-1] += 1;
        }
        imos[t*2] -= 1;
    }
    vector<int> sum(imos.size());
    partial_sum(imos.begin(), imos.end(), sum.begin());
    int ans = *max_element(sum.begin(), sum.end());
    cout << ans << endl;
}

Measured memory_bytes: 2944
#include <chrono>
#include <iostream>

using namespace std;
using namespace std::chrono;

string apply(const string& s, const string& t, int pos) {
  if (pos + t.length() > s.length())
    return "";

  string res = "";
  for (int i = 0; i < pos; ++i)
    res += (s[i] == '?' ? 'a' : s[i]);

  for (size_t i = pos; i < pos + t.length(); ++i) {
    if (s[i] == '?')
      res += t[i - pos];
    else if (s[i] == t[i - pos])
      res += s[i];
    else
      return "";
  }

  for (size_t i = pos + t.length(); i < s.length(); ++i)
    res += (s[i] == '?' ? 'a' : s[i]);

  return res;
}

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s, t;
  cin >> s >> t;
  string res = "";
  for (size_t i = 0; i < s.length(); ++i) {
    string tmp = apply(s, t, i);
    if (tmp != "") {
      if (res == "" || res > tmp)
        res = tmp;
    }
  }
  cout << (res == "" ? "UNRESTORABLE" : res) << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
x = list(map(int, input().split()))
if n >= m:
    print(0)
else:
    x.sort()
    ku = []
    for i in range(len(x)-1):
        ku.append(abs(x[i]-x[i+1]))
    ku.sort()
    sum = 0
    for i in range(m-n):
        sum += ku[i]
    print(sum)

Measured memory_bytes: 56872
// The very basic /////////////////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ALL_H 1

// Print elements of containers using << operator /////////////////////////////
// pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  return s << "(" << p.first << ", " << p.second << ")";}
// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  for (auto &elem : v) {
    s << elem;
    if (&elem != &v.back()) s << " ";
  }
  return s;
}
// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  for (auto &elem : vv) {
    s << elem;
    if (&elem != &vv.back()) s << endl;
  }
  return s;
}
// map
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
  s << "{" << endl;
  for (auto &elem: m) {
    s << " " << elem.first << " : " << elem.second << endl;
  }
  s << "}";
  return s;
}
//set
template<typename T> ostream& operator<<(ostream& s, const set<T>& m) {
  s << "{ ";
  for (auto &elem: m) {
    s << elem << " ";
  }
  s << "}";
  return s;
}

// Convenient macros //////////////////////////////////////////////////////////

// types
#define ll long long
#define ld long double
#define int ll
#define Pi pair<int, int>
#define Graph vector<vector<int>>
#define WeightGraph vector<vector<Pi>>

// other
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

#define MOD 1000000007
#define INF LLONG_MAX/100

// update max or min //////////////////////////////////////////////////////////

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

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

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


// Debug it by D(x) ///////////////////////////////////////////////////////////
#define DEBUG 1
#if DEBUG
#define D(x) x
#else
#define D(x)
#endif

///////////////////////////////////////////////////////////////////////////////
//                             Start Coding Here                             //
///////////////////////////////////////////////////////////////////////////////

signed main() {
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  rep(i, N-2) {
    if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') ans++;
  }
  cout << ans << endl;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int a[m + 1], s = 0;
    for(int i = 1; i <= m; i++)
        cin >> a[i], s += a[i];
    cout << max(-1, n - s);
}


Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;

    //auto compare = [](pair<int, int> a, pair<int, int> b) {
    //    return a.first < b.first;
    //};
    //priority_queue<pair<int, int>, vector<pair<int, int>, decltype(compare)>> qa;
    priority_queue<pair<int, int>> qa;

    for (int i = 0; i < n; i++)
    {
        pair<int, int> p1;
        cin >> p1.first >> p1.second;
        p1.first = -p1.first;
        qa.push(p1);
    }

    priority_queue<int> q;
    int ans = 0;
    for (int i = -1; i > -m - 1; i--)
    {
        if (!qa.empty())
        {
            while (qa.top().first >= i)
            {
                q.push(qa.top().second);
                qa.pop();
                if (qa.empty()) {
                    break;
                }
            }
        }

        if (!q.empty())
        {
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<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; }

bool vis[100100];

void func(long long N, std::vector<long long> a){

    lli cnt = 0;
    lli now = 0;
    while(1){
        if(vis[now]){
            cout<<-1<<endl;
            return;
        }
        if(now==1)break;
        vis[now]=true;
        cnt++;
        now = a[now];
    }

    cout<<cnt<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
        a[i]--;
    }
    func(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1152
number = int(input())

index = 1
while index <= number:
    current = index
    if current % 3 == 0:
        print(f" {index}", end="")
    else:
        while current != 0:
            if current % 10 == 3:
                print(f" {index}", end="")
                break
            current //= 10
    index += 1 
print("")


Measured memory_bytes: 5884
def fa():  # final answer
    global ans
    print(ans)


def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))

def check_mine(i,j,place):
    if place[i][j] == "#":
        return "#"

    num = 0
    for x in range(i-1, i+2):
        for y in range(j-1, j+2):
            try:
                if place[x][y] == "#":
                    if x >= 0 and y >= 0:
                        num += 1
            except:
                pass

    return str(num)

h, w = getList()

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


for i in range(h):
    ans = []
    for j in range(w):
        ans.append(check_mine(i,j,place))
    print("".join(ans))

Measured memory_bytes: 3064
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<queue>
#include<string>
#include<unordered_set>
#include<vector>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000;

string s,t,u;
ll a,b;

int main(){
    cin >> s >> t >> a >> b >> u;
    if(s==u){
        cout << a - 1 << " " << b << endl;
    }else{
        cout << a << " " << b - 1 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;

int main() {
  int a, b;
  cin >> a >> b;
  string ans;
  if(a <= 0 && b >= 0)
    ans = "Zero";
  else if(a > 0)
    ans = "Positive";
  else {
    if((a-b+1)%2)
      ans = "Negative";
    else
      ans = "Positive";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256