akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string s = Console.ReadLine();
            if(s == "ABC")
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("ABC");
            }
            
        }
    }
}

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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (long long)1e18 + 1;

class UnionFind {
public:
    struct Node {
        long long parent, rank, weight;
        Node() = default;
        Node(const long long& _parent,
             const long long& _rank,
             const long long& _weight = 0) :
            parent(_parent),
            rank(_rank),
            weight(_weight) { }
    };

    std::vector<Node> node;

    UnionFind(const long long& num_node) :
        node(num_node) {
        for(long long i = 0; i < num_node; i++) {
            node[i].parent = i;
        }
    }

    long long searchAndZipRoot(const long long& x) {
        if(node[x].parent == x) {
            return x;
        }
        else {
            auto r = searchAndZipRoot(node[x].parent);
            node[x].weight += node[node[x].parent].weight;
            return node[x].parent = r;
        }
    }

    long long calcWeight(const long long& x) {
        searchAndZipRoot(x);
        return node[x].weight;
    }

    void unite(const long long& x,
               const long long& y,
               const long long& weight = 0) {
        auto rx = searchAndZipRoot(x);
        auto ry = searchAndZipRoot(y);
        auto yw = weight + calcWeight(x) - calcWeight(y);
        if(rx != ry) {
            if(node[rx].rank < node[ry].rank) {
                std::swap(rx, ry);
                yw *= -1;
            }
            node[ry].parent = rx;
            node[ry].weight = yw;
            if(node[rx].rank == node[ry].rank) {
                node[rx].rank++;
            }
        }
    }

    long long calcDiff(const long long& x,
                       const long long& y) {
        return std::abs(calcWeight(x) - calcWeight(y));
    }

    template<class... A>
    bool checkWhetherRootIsSame(const A&... nodes) {
        auto node_list = std::initializer_list<long long>{nodes...};
        if(node_list.size() < 2) return false;
        auto v = searchAndZipRoot(*node_list.begin());
        for(size_t i = 1; i < node_list.size(); i++) {
            if(v != searchAndZipRoot(*(node_list.begin() + i))) return false;
        }
        return true;
    }
};

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

    int N, M;
    std::cin >> N >> M;

    UnionFind tree(N);

    string ans = "Yes";
    REP(i, M) {
        int l, r, d;
        std::cin >> l >> r >> d;
        l--; r--;

        if(!tree.checkWhetherRootIsSame(l, r)) {
            tree.unite(l, r, d);
        }
        else {
            auto diff = tree.calcDiff(l, r);
            if(diff != d) {
                ans = "No";
                break;
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 2560
s = list(input())
#d = {}
#for si in s:
#  if si in d:
#    d[si] += 1
#  else:
#    d[si] = 1
#mx = 0
#for k,v in d.items():
#  if v > mx:
#    mx = v
#t = []
#for k,v in d.items():
#  if v == mx:
#    t.append(k)
t = set(s)
#print(t)

s = ''.join(s)
ans = 101
for ti in t:
  s1 = s
  cnt = 0
  while(s1.count(ti) != len(s1)):
    #print(ti,cnt,s1)
    s2 = ''
    for i in range(len(s1)-1):
      if s1[i] == ti or s1[i+1] == ti:
        s2 += ti
      else:
        s2 += s[i]
    s1 = s2
    cnt += 1
  ans = min(cnt,ans)
print(ans)


Measured memory_bytes: 41324
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 042C

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    rep(i, k) cin >> d[i];
    vector<int> s(9);
    iota(s.begin(), s.end(), 0);
    vector<int>  ss;
    set_difference(s.begin(), s.end(), d.begin(), d.end(), back_inserter(ss));
    int ans = n;
    bool flag = true;

    while(flag){
        string tmp = to_string(ans);
        int nn = tmp.size();
        flag = false;
        rep(i, nn){
            rep(j, d.size()){
                if(tmp[i]-'0' == d[j]){
                    flag = true;
                    break;
                }
            }
            if(flag) break;
        }
        if(!flag) break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
ll N=1e9+7;
int main()
{
	ll n;
	cin>>n;
	if(n==1)
	{
		cout<<0<<endl;
		return 0;
	}

	if(n==2)
	{
		cout<<2<<endl;
		return 0;
	}

	ll tot=1,exc=1,ff=1;

	for(int i=0;i<n;i++)
	{
		tot*=10ll;
		tot%=N;
		exc*=8;
		exc%=N;
		ff*=9;
		ff%=N;
	}

	ff=tot-ff;

	if(ff<0)
	{
		ff+=N;
		ff%=N;
	}

	ff*=2;

	ff%=N;

	tot-=exc;

	if(tot<0)
	{
		tot+=N;
		tot%=N;
	}

	ll final=ff-tot;

	if(final<0)
	{
		final+=N;
		final%=N;
	}

	cout<<final<<endl;
	

	

	






	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

const int mod = 1000000007;
//const int mod = 998244353;

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

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

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

mint choose(int n,int a){
    mint x=1;
    mint y=1;
    for(int i = 0; i < a; i++) {
        x*=n-i;
        y*=i+1;
    }
    return x/y;
}

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> icnt(n,0);
    vector<int> ocnt(n,0);

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(a[i]>a[j]) ocnt[i]++;
            if(i<j&&a[i]>a[j]) icnt[i]++;
        }
    }

    ll kk=(k*(k-1)/2)%mod;
    ll ans=0;
    for(int i = 0; i < n; i++) {
        ans=(ans+(kk*ocnt[i])%mod)%mod;
        ans=(ans+(k*icnt[i])%mod)%mod;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>

int main(void)
{
  int i;
  int check = 0;
  char s[20];
  char t[20];
  scanf("%s%s", s, t);
  
  for (i = 0; i < strlen(s); i++) {
     if (s[i] != t[i]) {
        check = 1;
     }
  }
  if (check == 0) printf("Yes");
  if (check == 1) printf("No");
  return 0;
}

Measured memory_bytes: 1728
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+7
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define unsort(vec) sort((vec)); rever((vec));
using namespace std;

bool gu(string s) {
	int e=s.size();
	int g=e/2;
	int ans=0;
	if(e%2==1) {
		return false;
	}
	else {
		for(int i=0;i<g;i++) {
			if(s[i]==s[i+g]) {
				ans++;
			}
		}
		if(ans==(e/2)) {
			return true;
		}
		else {
			return false;
		}
	}
}

int main() {
	string s;
	cin>>s;
	int e=s.size();
	for(int i=0;i<e;i++) {
		int f=s.size()-1;
		s.erase(s.begin()+f);
		if(gu(s)) {
			cout<<s.size()<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
def printAns( A ):
    n = len(A)
    for i in range(1, n-1):
        print( str( A[i] ), end=" ")
    print( str( A[n-1] ) )

def main():
    n = int( input() )
    A = [0]
    list = [int(x) for x in input().split()]
    A.extend(list)
    B = []
    C = []
    k = max(A)

    for i in range(k + 1):
        C.append(0)

    for i in range(n+1):
        B.append(0)

    for j in range(1, n+1):
        C[ A[j] ] += 1

    for i in range(1, k+1):
        C[i] = C[i] + C[i-1]

    for j in reversed(range(n+1)):
        B[ C[ A[j] ] ] = A[j]
        C[ A[j] ] -= 1

    printAns(B)

if __name__ == "__main__":
    main()



Measured memory_bytes: 224228
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


int main() {
    LL A;cin >> A;
    double B;cin >> B;
    double C = B * 10000.0;
    C = round(C);

    LL D = (LL)(C);  
    D /= 100;

    LL ans = A*D;
    ans /= 100;

    cout << ans << endl;

    


}


Measured memory_bytes: 3756
s = input()
abc = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
ABC =['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
if s in abc:
  print('a')
elif s in ABC:
  print('A')

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

typedef long long ll;
typedef pair<int,int> P;
#define INF (int)(1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i = 1;i <= (int)(n); i++)
#define FOR(i,k,n) for(int i = (k); i < (int)(n); i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define pb push_back
#define vec vector<int>


/*--------------------------------------------*/
/*ll factorial(ll);
void list_Prime(ll);
ll divisor(ll);
ll lcm(ll, ll);//AとBの最小公倍数
ll gcd(ll,ll);

int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
*/
/*--------------------------------------------*/
/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}
ll lcm(ll A, ll B) {//最小公倍数
    ll a = A;
    ll b = B;
    if (a == 0 || b == 0) { return 0; }
    if (a < 0) { a = -a; }
    if (b < 0) { b = -b; }
    while (b > 0) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return A/a*B;
}

ll gcd(ll a,ll b){
    while (b != 0) {
        int t = b;
        b = a % b;
        a = t;
    }
    return a;
}


void list_Prime(ll n){//n以下の素数を全て見つける
    ll Limit=(int)sqrt((double)n);
    for(ll i=2;i<=n;i++)prime[i]=1;//最初はみんな素数かも
    //素数の整数倍を消していく(ルートnまで)
    for(ll i=2;i<=Limit;i++){
        if(prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    prime[j]=0;                
                }
            }
        }
    }
}

ll divisor(ll n){
    for(ll i=2;i<=n;i++){
        ll d=1;
        ll tmp=i;
        while(tmp>0){
            d++;
            while(tmp%d==0){
                prime[i]++;
                tmp/=i;
            }
        }
    }
    ll sum=1;
    for(ll i=2;;i<=n;i++){
        sum*=(prime[i]+1)/MOD;
    }    
    cout<<"sum="<<sum<<endl;

    return sum%MOD;
}
*/
/*--------------------------------------------*/

int main(){
    string ps,t;cin>>ps>>t;
    int n=(int)ps.size();
    int num=INF;
    int flag;
    int perfect;
    //cout<<n-(int)t.size()+1<<endl;
    rep(i,n-(int)t.size()+1){
        flag=1;perfect=1;
        rep(j,t.size()){
            if(t[j]==ps[i+j] || ps[i+j]=='?'){
                if(ps[i+j]=='?'){perfect=0;}
                continue;
            }
            else {flag=0;perfect=0;}
        }
        if(perfect==1){num=i;break;}//perfectならそこで確定
        if(flag==1)num=i;//もっとも良い(後ろの)numを見つける
    }
    if(num==INF)cout<<"UNRESTORABLE"<<endl;
    else{
        for(int i=0;i<n;){
            if(i==num){cout<<t;i+=(int)t.size();}
            else if(ps[i]=='?'){cout<<'a';i++;}
            else{cout<<ps[i];i++;}
        }cout<<endl;
    }
    
}



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

int main(void) {

	string s;
	cin >> s;

	int count = 0;

	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == '1')
			count++;
	}

	cout << count << "\n";
	return 0;
}

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

int main(){
    int b1[3][10] = {{}};
    int b2[3][10] = {{}};
    int b3[3][10] = {{}};
    int b4[3][10] = {{}};
    int n;
    cin >> n;
    for (int i=0;i<n;i++){
        int b,f,r,v;
        cin >> b >> f >> r >> v;
        if (b==1){
            b1[f-1][r-1] +=  v;
        }else if(b==2){
            b2[f-1][r-1] += v;
        }else if (b==3){
            b3[f-1][r-1] += v;
        }else if (b==4){
            b4[f-1][r-1] += v;
        }
    }
    int j,k,l;
    for(j=0;j<4;j++){
        for(k=0;k<3;k++){
            for (l=0;l<10;l++){
                if (j==0){
                    cout << " " << b1[k][l];
                }else if (j==1){
                    cout << " " << b2[k][l];
                }else if (j==2){
                    cout << " " << b3[k][l];
                }else if (j==3){
                    cout << " " << b4[k][l];
                }
            }cout << endl;
        }
        if (j!=3) cout << "####################" << endl;
    }
    return 0;

}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <math.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FLL(i,L,R) for (long long int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}, {-1,1}, {-1,-1} };

int n,m;
LL sum = 0;

void dane() {
    cin>>n>>m;
    F(i,0,m) {
        int a;
        cin>>a;
        sum+=a;
    }
    if(sum >n) {
        cout<<"-1\n";
        return;
    } else {
        cout<<(n-sum)<<endl;
    }
}

int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

Measured memory_bytes: 3656
// C - A x B + C
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; cin>>n; --n;
	int c = 0;
	for(int x=1; x*x<=n; ++x) c += (n / x - x) * 2 + 1;
	cout<< c <<endl;
}


Measured memory_bytes: 3572
n=int(input())
x=[int(i) for i in input().split()]
dp=[0 for i in range(n)]
dp[0]=0
dp[1]=abs(x[1]-x[0])
if n > 2:
  dp[2]=min(abs(x[2]-x[0]),dp[1]+abs(x[1]-x[0]))
  for i in range(2,len(x)):
      dp[i]=min(abs(x[i]-x[i-2])+dp[i-2],dp[i-1]+abs(x[i]-x[i-1]))
print(dp[-1])

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

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

  int max_diff = 0, max_value = A[N - 1], ans = 0;
  for (int i = N - 2; i >= 0; i--) {
    if (A[i] > max_value) {
      max_value = A[i];
    } else if (max_value - A[i] == max_diff)
      ans++;
    else if (max_value - A[i] > max_diff) {
      ans = 1;
      max_diff = max_value - A[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include<stdio.h>
using namespace std;
int main ()
{
    int a,b;
    cin>>a>>b;
    double c=a,d=b;
    
    //cout<<a/b<<" "<<a%b<<" "<<c/d<<endl;
    printf("%d %d %.5f\n",a/b,a%b,c/d);
    return 0;
}


Measured memory_bytes: 3204
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stdio.h>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if ((A % 2 == 0) || (B % 2 == 0)) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
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; }

const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
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;
    }
}

// 二項係数計算
long long 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;
}

// N-K+1 C i * K-1 C i-1
int main() {
  int N, K; cin >> N >> K;
  COMinit();

  for (int i = 1; i <= K; i++) {
    long long ans = COM(K - 1, i - 1) * COM(N - K + 1, i);
    ans %= MOD;
    cout << ans << endl;
  }

  return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int ctoi(char c) {
  return c - '0';
}

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

int main() {
  string s;
  cin >> s;
  string ans = "ABC" + s;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

use std::collections::VecDeque;

fn main() {
    input! {
        n: usize,
        x: usize1,
        y: usize1,
    }

    let mut dp = vec![vec![0; n]; n];

    for i in 0..n {
        for j in i..n {
            dp[i][j] = j - i;
        }
    }

    let mut queue = VecDeque::new();
    queue.push_back((x, y, 1));

    while let Some((x, y, v)) = queue.pop_front() {
        if dp[x][y] <= v {
            continue;
        }

        dp[x][y] = v;
        if x > 0 {
            queue.push_back((x - 1, y, v + 1));
        }
        if x < n - 1 {
            queue.push_back((x + 1, y, v + 1));
        }
        if x < y {
            queue.push_back((x, y - 1, v + 1));
        }
        if y < n - 1 {
            queue.push_back((x, y + 1, v + 1));
        }
    }

    let mut res = vec![0; n];

    for i in 0..n {
        for j in i..n {
            res[dp[i][j]] = res[dp[i][j]] + 1;
        }
    }

    for i in 1..n {
        println!("{}", res[i]);
    }
}


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

using namespace std;

char mp[1000][1000];
char e[2][2];

int dx[4] = {-1, 0, -1, 0}, dy[4] = {-1, -1, 0, 0};
char a[3] = {'J', 'O', 'I'};

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

    for (int i = 0; i < h; ++i) cin >> mp[i];

    for (int i = 0; i < 2; ++i) cin >> e[i];

    int sum = 0;

    for (int i = 0; i < h - 1; ++i) {
        for (int j = 0; j < w - 1; ++j) {
            if (mp[i][j] == e[0][0] && mp[i][j + 1] == e[0][1] && mp[i + 1][j] == e[1][0] && mp[i + 1][j + 1] == e[1][1]) {
                sum++;
            }
        }
    }

    int ans = sum;

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int sum2 = sum;

            char tmp = mp[i][j];

            int cnt = 0;

            for (int k = 0; k < 4; ++k) {
                int y = i + dy[k], x = j + dx[k];
                if (y < 0 || x < 0 || y + 1 >= h || x + 1 >= w) continue;
                if (mp[y][x] == e[0][0] && mp[y][x + 1] == e[0][1] && mp[y + 1][x] == e[1][0] && mp[y + 1][x + 1] == e[1][1]) {
                    cnt++;
                }
            }

            sum2 -= cnt;
            
            for (int k = 0; k < 3; ++k) {
                mp[i][j] = a[k];

                int cnt2 = 0;

                for (int l = 0; l < 4; ++l) {
                    int y = i + dy[l], x = j + dx[l];
                    if (y < 0 || x < 0 || y + 1 >= h || x + 1 >= w) continue;
                    if (mp[y][x] == e[0][0] && mp[y][x + 1] == e[0][1] && mp[y + 1][x] == e[1][0] && mp[y + 1][x + 1] == e[1][1]) {
                        cnt2++;
                    }
                }

                cnt = max(cnt, cnt2);
            }

            sum2 += cnt;

            mp[i][j] = tmp;

            ans = max(ans, sum2);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 2140
import sys
n = int(input())
x = 0
for i in range(1,n+1):
    if i % 3 == 0:
        print(" %d"%i, end = "");
    else:
        x = i
        while (x):
            if x % 10 == 3:
                print(" %d"%i, end = "")
                break
            x //= 10
print()



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

int main()
{
  int n;
  cin >> n;
  vector<int64_t> a(n);

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

  sort(begin(a), end(a));
  int64_t ans(0);

  if (n % 2 != 0) {
    for (int i = 0; i < n; i++) {
      int64_t t = a[i] - a[(n - 1) / 2];
      ans += t < 0 ? -t : t;
    }
  } else {
    int64_t x(0), y(0);
    for (int i = 0; i < n; i++) {
      int64_t t = a[i] - a[n / 2 - 1];
      int64_t u = a[i] - a[n / 2];
      x += t < 0 ? -t : t;
      y += u < 0 ? -u : u;
    }
    ans = min(x, y);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
using namespace std;

bool equal(string s1, string s2) {
	if (s1.length() != s2.length())return false;
	for (int i = 0; i < s1.length(); i++) {
		if (s1[i] != s2[i])return false;
	}
	return true;
}

int count(vector<string> a, string s) {
	int cnt = 0;
	for (int i = 0; i < a.size(); i++) {
		if (equal(a[i], s))cnt++;
	}
	return cnt;
}

int main() {
	int n, m, ans = -1000;
	cin >> n;
	vector<string>s, t;
	for (int i = 0; i < n; i++) {
		string p;
		cin >> p;
		s.emplace_back(p);
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		string p;
		cin >> p;
		t.emplace_back(p);
	}
	for (int i = 0; i < n; i++) {
		string f = s[i];
		int sc = count(s, f);
		int tc = count(t, f);
		ans = max(ans, sc - tc);
	}
	cout << max(ans, 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << n / (a + b) * a + min(n % (a + b), a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    if(N==M){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	std::set<int> all;
	for (int i = 0; i < n; i++) all.insert(ri());
	std::cout << all.size() << std::endl;
	return 0;
}





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

void solve()
{
	int n;
	cin>>n;
	int height[n];
	for(int i=0;i<n;++i) cin>>height[i];
	map<int,int>occur;
	for(int i=0;i<n;++i) occur[i-height[i]]++;
	long long pair=0;
	for(int i=0;i<n;++i) pair+=(long long)occur[i+height[i]];
	cout<<pair;
	return;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}

Measured memory_bytes: 21360
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int A,B,T;
  cin>>A>>B>>T;
  int x = T/A;
  cout << x*B << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int in[200001];
int a[200001];
 int main() {
	 int N;
	 cin >> N;
	 for (int i = 1; i <= N; i++) cin >> a[i];
	 int M = 0;
	 for (int i = N; i >= 1; i--) {
		 in[i] = a[i];
		 for (int j = i * 2; j <= N; j += i) {
			 in[i] ^= in[j];
		 }
		 if (in[i]) M++;
	 }
	 cout << M << endl;
	 if (M > 0) {
		 for (int i = 1; i <= N; i++) {
			 if (in[i]) cout << i << " ";
		 }
		 cout << endl;
	 }
}

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

int MAX_N = 100001;
vector<int>is_prime(MAX_N, 1);

int Eratosthenes(int MAX_N) {
    is_prime[0] = is_prime[1] = 0;
    for (int i = 2; i <= MAX_N; i++) {
        if(is_prime[i]) {
            for (int j = 2 * i; j <= MAX_N; j += i ) {
                is_prime[j] = 0;
            }
        }
    }   
}

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

    Eratosthenes(MAX_N);

    vector<int> a(MAX_N, 0);
    for (int i = 0; i <MAX_N; i++) {
        if (i % 2 == 0 ) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }

    vector<int> s(MAX_N+1, 0);
    rep(i, MAX_N) s[i+1] = s[i] + a[i];

    rep(i, q) {
        int l, r;
        cin >> l >> r;
        r++;
        cout << s[r] - s[l] << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef queue<pi> qpi;
typedef queue<pl> qpl;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pql;
typedef priority_queue<pi> pqpi;
typedef priority_queue<pl> pqpl;

#define read freopen("in.c", "r", stdin)
#define write freopen("out.c", "w", stdout)
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define ff first
#define ss second
#define left(x) ((x) + (x) + 1)
#define right(x) ((x) + (x) + 2)
#define pb push_back
#define pp pop_back
#define eps 1e-9

ll in()
{
    ll a;
    scanf("%lld", &a);
    return a;
}

int main()
{
    string a, b;
    cin >> a >> b;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());
    if(a < b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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


int main() {
  long long int  N,D, cnt = 0;;
  string S;
  //vector<vector<long long int>> hit_v;
  cin >> N >> D;
  vector<vector<long long int>> x_v(N, vector<long long int>(D));

  for (int i = 0; i < N; i++) {
    //x_v.push_back({});
    for (int j = 0; j < D; j++) {
      long long int x;
      cin >> x;
      x_v[i][j] = x;
      //cout << x_v[i][j] << endl;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      //cout << x_v[i][j];
    }
    //puts("");
  }
  
  for (int i = 0; i < N-1; i++) {
    for (int j = i+1; j < N; j++) {
      //cout << i << j << endl;

      long long int d = 0;
      for (int k = 0; k < D; k++) {
        d += ((x_v[i][k] - x_v[j][k]) * (x_v[i][k] - x_v[j][k]));
        //cout << x_v[i][k] << endl;
      }
      //cout << d << endl;
      //     cout << ceil(sqrt(d)) << "  "<< floor(sqrt(d));
      if (ceil(sqrt(d)) != floor(sqrt(d))) {
        ;
      }
      else {
        cnt ++;
      }
    }
  }
  cout << cnt << endl;
  //cout << c_cnt << " " << d_cnt << " " << cd_cnt << " " << endl;

  // k - C - D + CD
  // k = 0;
  // long long int tmp = A / C;
  // k = (tmp-1)*C;
  // while (1) {
  //   k += C;
  //   if (k > B) break;
  //   if (A <= k) c_cnt++;
  // }
  // k = 0;
  // long long int tmp = A / D;
  // k = (tmp-1)*D;
  // while (1) {
  //   k += D;
  //   if (k > B) break;
  //   if (A <= k) d_cnt++;
  // }
  // k = 0;
  // long long int a = lcm(C, D);
  // long long int tmp = A / a;
  // k = (tmp-1)*a;
  // //cout << a << endl;
  // while (1) {
  //   k += a;
  //   if (k > B) break;
  //   if (A <= k) cd_cnt++;
  // }
  //cout << c_cnt << " " << d_cnt << " " << cd_cnt << " " << endl;
  // for (int i = 0; i < Q; i++) {
  //   long long int l, r;
  //   cin >> l >> r;
  //   l_v.push_back(l);
  //   r_v.push_back(r);
  // }

  // for (int i = 0; i < S.size()-1; i++) {
  //   if (S[i] == 'A' && S[i+1] == 'C') {
  //     cnt++;
  //     hit_v.push_back({i, i+1});
  //   }
  // }
  // for (int i = 0; i < Q; i++) {
  //   cnt = 0;
  //   for (int j = 0; j < hit_v.size(); j++) {
  //     if (l_v[i]-1 <= hit_v[j][0] && hit_v[j][1] <= r_v[i]-1) {
  //       cnt ++;
  //     }
  //     else if (hit_v[j][1] > r_v[i]-1) {
  //       break;
  //     }
  //   }
  //   cout << cnt << endl;
  // } 
  
  // char S[1000000] = {0};
  // vector<int> s_v, s_01v, s_10v;
  // cin >> S;
  // //cout << strlen(S) << endl;
  // for (int i = 0; i < strlen(S); i++) {
  //   s_v.push_back(S[i] - '0');
  //   switch(i%2) {
  //   case 0:
  //     s_01v.push_back(0);
  //     s_10v.push_back(1);
  //     break;
  //   case 1:
  //     s_01v.push_back(1);
  //     s_10v.push_back(0);
  //     break;
  //   }
  // }
  // long long int cnt_01 = 0, cnt_10 = 0;

  // for (int i = 0; i < strlen(S); i++) {
  //   if (s_01v[i] != s_v[i]) cnt_01++;
  //   if (s_10v[i] != s_v[i]) cnt_10++;
  // }
  // if (cnt_01 > cnt_10) {
  //   cout << cnt_10 << endl;
  // }
  // else {
  //   cout << cnt_01 << endl;
  // }
  // for (int i = 0; i < strlen(S); i++) {
  //   printf("%d ", s_v[i]);
  // }
  return 0;
}


Measured memory_bytes: 256
n, y = map(int, input().split())
flag = 1
for i in range(n+1):
    for j in range(n+1-i):
        if (10000 * i + 5000 * j + 1000 * (n-i-j)) == y and flag:
            print(i, j, n-i-j)
            flag = 0
if flag:
    print(-1, -1, -1)

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define Set(i, v) memset(i, v, sizeof i)

using namespace std;

const int N = 2e5 + 10;

char S[N];
int n, cnt[26];
stack<int> s[26];

int c[N];

int lowbit(int x){
	return x & (-x);
}

void add(int x){
	while(x <= n){
		c[x]++;
		x += lowbit(x);
	}
}

int sum(int x){
	int ret = 0;
	while(x){
		ret += c[x];
		x -= lowbit(x);
	}
	return ret;
}

int main(){

	scanf("%s", S + 1);
	n = strlen(S + 1);
	For(i, 1, n) cnt[S[i] - 'a']++, s[S[i] - 'a'].push(i);
	int ct = 0;
	For(i, 0, 25) if(cnt[i] & 1) ++ct;
	
	if(ct > 1){
		puts("-1");
		return 0;
	}

	long long ans = 0;
	int i = 1;
	For(j, 1, n / 2){
		while(sum(n + 1 - i) - sum(n - i)) ++i;
		int x = S[i] - 'a';
		if(cnt[x] == 1) ans += n / 2 + 1 - j, --j;
		else{
			assert(cnt[x] >= 2);
			cnt[x] -= 2;
			ans += n - s[x].top() - sum(n + 1 - s[x].top());
			add(n + 1 - s[x].top());
			s[x].pop();
		}
		add(n + 1 - i);
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 2048
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>
#include <iomanip>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
ll A[200005] = {};
ll B[200005] = {};
ll C[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl[3];
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}



ll minn, maxx;
double ansa;
bool fl[4];


int main() {

	cin >> S[0];

	e = S[0].size() * (S[0].size() - 1)/2;
	e++;

	for (int i = 0; i < S[0].size(); i++) {
		A[S[0][i] - 'a']++;
	}

	for (int i = 0; i <= 25; i++) {
		e -= (A[i] - 1) * A[i]/2;
	}

	cout << e << endl;

	return 0;

}


Measured memory_bytes: 2564
#include <iostream>
#include <vector>
#include <algorithm>

typedef long long ll;
typedef std::pair< ll, ll > P;
const ll INF = 1e12;
const ll MAX_N = 1e5;

int main(int argc, char* argv[])
{
  ll N, M;
  std::cin >> N >> M;
  std::vector< P >  vp(M, std::make_pair(0, 0));

  for (ll i = 0; i < M; i++) {
    std::cin >> vp[i].second >> vp[i].first;
  }

  std::sort(vp.begin(), vp.end());
  std::vector< P >::iterator it;
  ll ans = 0;
  ll pos = -1;
  for (it = vp.begin(); it != vp.end(); it++) {
    if (it->second > pos) {
      ans++;
      pos = it->first-1;
    }
  }

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


Measured memory_bytes: 1792
n = int(input())
lst = [(bin(i)[2:]).zfill(n) for i in range(2**n)]
num_list = []
A_list = []
xy_list = []
for i in range(n):
    a = int(input())
    A_list.append(a)
    for j in range(a):
        x,y = map(int,input().split())
        xy_list.append([x,y])
for i in range(len(lst)):
    choose = lst[i]
    one_count = choose.count("1")
    a_count = 0
    flag = True
    for num, j in enumerate(A_list):
        a_count += j
        for k in range(a_count-j, a_count):
            x,y = xy_list[k][0],xy_list[k][1]
            if choose[num] == "1" and choose[x-1] != str(y):
                flag = False
                break
    if flag:
        num_list.append(one_count)
    else:
        num_list.append(0)
print(max(num_list))


Measured memory_bytes: 5672
a,b,c,x,y = map(int, input().split())
cost = [a*x+b*y]
cost.append(c*2*x+b*max((y-x),0))
cost.append(c*2*y+a*max((x-y),0))
cost.append(c*2*max(x,y))
print(min(cost))

Measured memory_bytes: 3188
import java.lang.Math.min
import java.lang.Math.abs

fun main(args: Array<String>) = ABC160C.main()

object ABC160C {
    fun log(message: Any?) {
        //println(message)// TODO: ←消す
    }

    val K: Int
    val N: Int
    val A: List<Int>    // 0-origin

    init {
        val (k, n) = readInts()
        K = k
        N = n
        A = readInts()

    }

    fun main() {
        val ans = (0 until N).map {
            dist(it)
        }.min()
        println(ans)
    }

    fun dist(i: Int): Int {
        val toIp = if (i < N - 1) abs(A[i + 1] - A[i]) else abs(A.first() + (K - A.last()))
        val toIm = if (0 < i) abs(A[i] - A[i - 1]) else abs(A.first() + (K - A.last()))
        val right = K - toIp
        val left = K - toIm

        log("$right, $left")
        return min(right, left)
    }

    /*####################################################################################*/

    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
}

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

int main() {
    char a, b, c, d;
    cin >> a >> b >> c >> d;
    int A, B, C, D;
    A = a - '0';
    B = b - '0';
    C = c - '0';
    D = d - '0';
    int now;
    for (int i = 0; i < 1<<3; i++){
        int ans = A;
        if(i>>2&1){
            ans += B;
        } else {
            ans -= B;
        }
        if(i>>1&1){
            ans += C;
        } else {
            ans -= C;
        }
        if(i&1){
            ans += D;
        } else {
            ans -= D;
        }
        if(ans == 7){
            now = i;
            break;
        }
    }

    char op1, op2, op3;
    if(now>>2&1){
        op1 = '+';
    } else {
        op1 = '-';
    }
    if(now>>1&1){
        op2 = '+';
    } else {
        op2 = '-';
    }
    if(now&1){
        op3 = '+';
    } else {
        op3 = '-';
    }

    cout << A << op1 << B << op2 << C << op3 << D << "=7" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
int main(){
    string S;
    cin >> S;
    int ans;
    if(S == "SUN")ans = 7;
    if(S == "MON")ans = 6;
    if(S == "TUE")ans = 5;
    if(S == "WED")ans = 4;
    if(S == "THU")ans = 3;
    if(S == "FRI")ans = 2;
    if(S == "SAT")ans = 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vi>;
using pii = pair<int, int>;

using vc = vector<char>;
using vcc = vector<vc>;
using vb = vector<bool>;
using vbb = vector<vb>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;

// n は 2以上の素数表を返す
vb Primes(int n){
  vector<bool> res(n + 1, true);
  res.at(0) = false; res.at(1) = false;
  for(int i = 2; i <= sqrt(n); i++){
    if(res.at(i)){
      for(int j = 2 * i; j <= n; j += i){
        res.at(j) = false;
      }
    }
  }
  return res;
}


int main(){
  int n; cin >> n;
  int max = 0, tmp, res = 0;
  for(int i = 0; i < n;i++){
    cin >> tmp;
    res += tmp;
    if(tmp > max) max = tmp;
  }
  res -= (max / 2);
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
import numpy as np 

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

A = []
B = []

for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

A = np.array(A)
B = np.array(B)

dp = np.zeros(H+1,dtype=np.int32)

for i in range(1,H+1):
    dp[i] = np.amin(dp[np.maximum(i-A,0)]+B)
    
print(dp[H])

Measured memory_bytes: 12508
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut result = true;
    for (i, v) in s.trim().chars().enumerate() {
        result = result && if i % 2 == 0 {
            match v {
                'R' | 'U' | 'D' => true,
                _               => false,
            }
        } else {
            match v {
                'L' | 'U' | 'D' => true,
                _               => false,
            }
        }
    }
    println!("{}", if result { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
<?php
  
$nm = explode(' ',trim(fgets(STDIN)));
$n = $nm[0];
$m = $nm[1];

$ans = 0;

$so = $m-$n*2;
if ($so == 0){
  $ans = $n;
} else if($so < 0){
  $ans = strval(floor($m/2)); 
} else {
  $ans = strval(floor($so/4)+$n);
}

echo $ans;
?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#include <algorithm>
#define TARGET_NUM 753

int ctoi(char c){
  return c - '0';
}

int main(){
  string s;
  cin >> s;
  
  int min_ans = 1000;
  for(int i = 0; i+2 < s.size(); i++){
    int num = ctoi(s[i]) * 100 + ctoi(s[i+1]) * 10 + ctoi(s[i+2]);
    if(min_ans > (int) abs(num - TARGET_NUM))
      min_ans = (int) abs(num - TARGET_NUM);
  }
  
  cout << min_ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    char m,ans;
    cin >> m;
    
    if(m == 'A') ans = 'T';
    else if(m == 'T') ans = 'A';
    else if(m == 'G') ans = 'C';
    else if(m == 'C') ans = 'G';
    
    cout << ans << endl;
    
}

Measured memory_bytes: 256
import scala.math._

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val p = List.fill(n)(sc.nextInt)

  val ans = p.foldLeft((0, (None, None, None)): (Int, (Option[Int], Option[Int], Option[Int])))((acc, v) => {
      val current = (acc._2._2, acc._2._3, Some(v))
      current match {
        case (Some(v1), Some(v2), Some(v3)) =>
          if (List(v1, v2, v3).sorted.apply(1) == v2) (acc._1 + 1, current)
          else (acc._1, current)
        case _ => (0, current)
      }
    }
  )._1

  println(ans)

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

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

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

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

int main(){
	int k,x;
	cin>>k>>x;

	if(k*500>=x){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<cmath>
#include<iomanip>
#include<cstdlib>
using namespace std;
int main(){
  string s;
  cin>>s;
  int start=0,end=s.size()-1;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'){
      break;
    }
    else{
      start+=1;
      continue;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='Z'){
      break;
    }
    else{
      end-=1;
      continue;
    }
  }
  cout<<end-start+1<<endl;
  
    return 0;
  
}


Measured memory_bytes: 640