akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;    

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    

int main() {    
    long n, m;
    cin >> n >> m;
    vector<long> a(n);
    vector<pair<long, long>> swaped;
    swaped.reserve(100000);
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<m; i++) {
        int b, c;
        cin >> b >> c;
        swaped.push_back(make_pair(b, c));
    }

    sort(a.rbegin(), a.rend());
    sort(swaped.begin(), swaped.end(), [](const pair<int, int> &a, const pair<int, int> &b) { return a.second > b.second; });
    
    //PRINT_ARRAY_WITH_LABEL("a", a);
    //for(int i=0; i<m; i++) {
    //    cout << swaped[i].first << " " << swaped[i].second << endl;
    //}

    long i_a = 0;
    long i_swap = 0;
    long sum = 0;
    while(n > 0) {
        long ca = a[i_a];
        pair<long, long> cswaped = swaped[i_swap];
        if(ca >= cswaped.second) {
            sum += ca;
            i_a++;
        } else {
            sum += cswaped.second; 
            cswaped.first--;
            swaped[i_swap] = cswaped;
            if(cswaped.first == 0) {
                i_swap++;
            }
        }
        n--;
    }

    cout << sum << endl;
    
    
    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}



Measured memory_bytes: 2560
# -*- coding: utf-8 -*-

N = int(input())
aN = list(map(int, input().split()))

# 初期値設定
sunuke = aN[0]
arai = sum(aN) - aN[0]
ans = abs(sunuke - arai)

for i in range(1, N-1):
    sunuke += aN[i]
    arai -= aN[i]
    ans = min(ans, abs(sunuke - arai))
print(ans)

Measured memory_bytes: 24832
import math
N = int(input())

ans = N / 1.08
ans_ceil = math.ceil(ans)
ans_floor = math.floor(ans)

if math.floor(ans_ceil * 1.08) == N:
  print(ans_ceil)
elif math.floor(ans_floor * 1.08) == N:
  print(ans_floor)
else:
  print(":(")

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
	int inputa,flag=0;
	scanf("%d", &inputa);
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			if((i*j)==inputa){
				flag=1;
				break;
			}
		}
	}
	if(flag==1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1660
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[])
{
	int n;
	int sum, score;
	int max, min;
	while (true) {
		sum = 0;
		max = -1;
		min = 1e4;
		scanf("%d", &n);
		if (!n)
			break;
		for (int i = 0; i < n; i++) {
			scanf("%d", &score);
			max = max < score ? score : max;
			min = min > score ? score : min;
			sum += score;
		}
		sum -= +max + min;
		printf("%d\n", sum / (n - 2));
	}
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  if (S == "SUN") cout << 7 << endl;
  else if (S == "MON") cout << 6 << endl;
  else if (S == "TUE") cout << 5 << endl;
  else if (S == "WED") cout << 4 << endl;
  else if (S == "THU") cout << 3 << endl;
  else if (S == "FRI") cout << 2 << endl;
  else if (S == "SAT") cout << 1 << endl;
  return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;
string s;

int main() {
    while (true) {
        cin >> n;
        if (n == 0) break;

        V<Pii> v(n);
        REP(i, n) {
            int h, m, s;
            int h2, m2, s2;
            scanf("%02d:%02d:%02d %02d:%02d:%02d\n", &h, &m, &s, &h2, &m2, &s2);
            v[i] = {s + m*100 + h*10000, s2 + m2*100 + h2*10000};
        }

        Vi cnt(3e6, 0);
        FOR(i, v) {
            cnt[i->first] += 1;
            cnt[i->second] -= 1;
        }

        int sum = 0, maxi = -1;
        REP(i, 3e6) {
            sum += cnt[i];
            maxi = max(maxi, sum);
        }
        std::cout << maxi << '\n';
    }

    return 0;
}



Measured memory_bytes: 15024
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int num=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())num=(num<<3)+(num<<1)+c-48;
	return num*f;
}
char s[5];
bool f[200]={0};
inline void init()
{
	scanf("%s",s+1);
	f[s[1]]=1;
	f[s[2]]=1;
	f[s[3]]=1;
	if(f[int('a')]&&f[int('b')]&&f[int('c')])cout<<"Yes";
	else cout<<"No";
}
void work()
{
	
}
int main()
{
	init();
	work();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
     int N,a;
	 scanf("%d",&N);
	 a=N%10;
	 if(a==2||a==4||a==5||a==7||a==9){
	    printf("hon\n");
	}
	 if(a==0||a==1||a==6||a==8){
	    printf("pon\n");
	}
	 if(a==3){
	    printf("bon\n");
	}
	return 0;
}
	 

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll x, k;
    cin >> x >> k;
    Array r(k);
    REP(i, k) {
        cin >> r[i];
    }

    ll a = 0;
    ll b = x;
    ll c = 0;
    ll t = 0;
    ll pos = 0;
    bool flag = true; //Aパーツが上にあるかどうか

    ll q;
    cin >> q;

    while(q--) {
        ll tt, aa;
        cin >> tt >> aa;
        while(pos < k and tt > r[pos]) {
            ll dt = r[pos] - t;
            if(flag) {
                c -= dt;
                chmax(a, -c);
                chmax(b, -c);
                flag = !flag;
            } else {
                c += dt;
                chmin(b, x - c);
                chmin(a, x - c);
                flag = !flag;
            }
            t = r[pos];
            pos++;
        }

        ll dt = tt - t;
        if(flag) {
            c -= dt;
            chmax(a, -c);
            chmax(b, -c);
        } else {
            c += dt;
            chmin(b, x - c);
            chmin(a, x - c);
        }
        t = tt;
        if(aa <= a) {
            cout << a + c << en;
        } else if(aa >= b) {
            cout << b + c << en;
        } else {
            cout << aa + c << en;
        }
    }
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3972
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <utility>

using namespace std;

long long bfac[100003];
long long pref[100003];
void precompute()
{
	for(int i = 1; i <= 100000; i++)
	{
		for(int j = 1; j <= sqrt(i); j++)
		{
			if(i%j == 0)
			{
				bfac[i]+=2;
				bfac[i]-=(long long)(j*j == i);
			}
		}
	}
	for(int i = 1; i <= 100000; i++)
		pref[i] = pref[i-1]+bfac[i];
}

int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//freopen("input.in", "r", stdin);
	long long n, k; scanf("%lld %lld", &n, &k);
	if(k == 0)
	{
		printf("%lld\n", n*n);
		return 0;
	}
	long long res = 0;
	for(long long i = k+1; i <= n; i++)
	{
		long long cyc = (n)/i;
		res += (cyc)*(i-k);
		res += max(0LL,(n%i)-(k-1));
	//	printf("i : %lld cyc : %lld res %lld\n", i, cyc, res);
	}
	printf("%lld\n", res);
}





Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <cassert>
#include <iostream>
#include <memory>
#include <unordered_map>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <fstream>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}

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



typedef unsigned __int128 Hash;

template<class T>
class RollingHash{
public:
	T src;
	vector<Hash> harr,p;
	
	RollingHash(T src,Hash w=8999):src(src){
		p.resize(src.size()+1);
		Hash sum = 0;
		for(int i = 0 ; i < src.size() ; i++){
			sum = sum * w + src[i];
			harr.push_back(sum);
		}
		p[0] = 1;
		for(int i = 1 ; i < p.size() ; i++){
			p[i] = p[i-1] * w;
		}

	}
	// [l,r)
	Hash sub(int l,int r) const{
		if( l >= r ) return 0;
		return harr[r-1] - (l?harr[l-1] * p[r-l]:0);
	}
};

int calc(string &s,int k){
	if( k == 0 ) return 0;

	RollingHash<string> RH(s);

	set<Hash> S;
	for(int i = 0 ; i < s.size() - k + 1 ; i++){
		S.insert(RH.sub(i,i+k));
	}
	return S.size();
}
int main(){
	string s;
	cin >> s;
	int l = 1, r = s.size();
	while( l != r ){
		int m = (l+r+1) / 2;
		if( calc(s,m) - calc(s,m-1) > 0 ){
			l = m;
		}else{
			r = m-1;
		}
	}
	cout << calc(s,l) << endl;

	/*
	for(int i = 1 ; i <= s.size() ; i++){
		cout << i << ": " << calc(s,i) << endl;
	}*/
}




Measured memory_bytes: 9780
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;
    String S;

    private void solve() {
        N = nextInt();
        S = next();

        int[] west = new int[N + 1];
        for(int i = 0;i < N;i++) {
            west[i + 1] = west[i] + (S.charAt(i) == 'W' ? 1 : 0);
        }

        int[] east = new int[N + 1];
        for(int i = 0;i < N;i++) {
            east[i + 1] = east[i] + (S.charAt(i) == 'E' ? 1 : 0);
        }

        int ans = Integer.MAX_VALUE;
        for(int i = 0;i < N;i++) {
            ans = Math.min(ans,west[i] + east[N] - east[i + 1]);
        }

        out.println(ans);
    }
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 27988
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	string s;
	cin>>s;
	int n=s.length();
	vector<int> ans(n);
	int cnt=0,lr=-1,ll=-1;
	FOR(i,0,n){
		if(s[i]=='R'){
			cnt++;
			lr=i;

		}else{
			if(i==lr+1){
				//cerr<<i<<" "<<cnt<<endl;
				ans[lr]+=(cnt+1)/2;
				ans[lr+1]+=(cnt)/2;
				cnt=0;
			}
			if((i-lr)&1){
				ans[lr+1]++;
			}else{
				ans[lr]++;
			}

		}
	}

	FOR(i,0,n){
		cout<<ans[i]<<" ";
	}

	return 0;
}


Measured memory_bytes: 1024
n, k = (int(i) for i in input().split())
w = [int(input()) for i in range(n)]

total_weght = sum(w)

def check(p):
    track = [0 for i in range(k)]
    target = 0

    for i in range(k):
        while (track[i] + w[target]) <= p:
            track[i] += w[target]
            target += 1
            if target not in range(n):
                break
        if target not in range(n):
            break
    
    return(target)

def solve(n):
    left = 0
    right = 100000 * 100000
    while left < right:
        
        mid = (left + right) // 2
        if n == check(mid):
            right = mid
        else:
            left = mid + 1

    return(right)

if __name__ == "__main__":
    ans = solve(n)
    print(ans)



Measured memory_bytes: 9568
#include<iostream>
#include<set>
using namespace std;
#define ll long long

struct Cake{
  ll id, n;
  Cake(ll _id, ll _n):id(_id), n(_n) {}
};

bool operator <(const Cake& lhs, const Cake& rhs) { return lhs.n>rhs.n; }

template<class T>
void print(T& cakes) {
  for(auto itr=cakes.begin(); itr!=cakes.end(); ++itr) {
    cout << itr->id << ":" << itr->n << "  ";
  }
  cout << endl;
}


int main(){
  ll K, T, a;
  cin >> K >> T;

  multiset<Cake> cakes;
  for(ll i=0; i<T; ++i) {
    cin >> a;
    cakes.emplace(i,a);
  }

  ll id_prev = -1;
  for(ll i=0; i<K; ++i) {
    auto itr = cakes.begin();
    if (itr->id == id_prev) ++itr;

    id_prev = itr->id;
    ll n = itr->n-1;
    cakes.erase(itr);

    if (n>0) cakes.emplace(id_prev, n);

    if (cakes.size()==1) break;
  }

  ll streak = cakes.begin()->n-1;
  if (id_prev == cakes.begin()->id) ++streak;
  cout << streak << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;
#define A cout << "Audrey wins." << endl
#define F cout << "Fabre wins." << endl

string i2s(int num){
  string s;
  stringstream ss;

  ss << num;
  ss >> s;

  return s;
}

int main(){
  int n;

  cin >> n;
  while(n--){
    string str;
    cin >> str;
    
    int cnt = 0;
    while(str.size() >= 2){
      cnt++;
      int pos = str.size()-2;
      int sum = (str[pos]-'0')+(str[pos+1]-'0');
      string tmp = i2s(sum);
      str = str.substr(0,pos) + tmp;
    }
    if(cnt%2) F;
    else A;    
  }
  return 0;
}

Measured memory_bytes: 1232
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

#define int long long

signed main() { 
        int n;
        cin >> n;
        vector<int> a(n), b(n);
        rep(i, n) cin >> a[i] >> b[i];
        int aa = a[0], bb = b[0];
        rer(i, 1, n - 1) {
                int d = max(aa / a[i], bb / b[i]);
                while (aa > a[i] * d || bb > b[i] * d) d ++;
                aa = a[i] * d;
                bb = b[i] * d;
        }
        cout << aa + bb << endl;
        return 0;
}               


Measured memory_bytes: 256
<?php

fgets(STDIN);

$a_tachi = explode(' ', trim(fgets(STDIN)));

sort($a_tachi);

if ($a_tachi[0] ==='0') {
    echo '0' . "\n";
    exit;
}

$mul = 1;
foreach ($a_tachi as $a) {
    $mul *= $a;
    if ($mul > 1000000000000000000) {
        echo '-1' . "\n";
        exit;
    }
}

echo $mul . "\n";


Measured memory_bytes: 25424
#include<stdio.h>

void replace(int *p,int *q){
  int esc;
  esc = *p;
  *p = *q;
  *q = esc;
}

int convert_x(char c[]){
  int f;
  f = c[0] -'0';
  if(c[1] != ','){
    f = f*10 + c[1] - '0';
  }
  return f;
}

int convert_y(char c[]){
  int f;
  if(c[1]==','){
    f = c[2] - '0';
    if(c[3]!=0){
      f = f*10 + c[3] - '0';
    }
  }

  else{
    f = c[3] - '0';
    if(c[4]!=0){
      f = f*10 + c[4] - '0';
    }
  }
  return f;
}
  
  
    

int main(void){
  int w,n;
  int x,y;
  int i;
  int a[30];
  char str[5];
  for(i=0;i<30;i++){
    a[i] = i + 1;
  }
  scanf("%d %d",&w,&n);
    
  for(i=0;i<n;i++){
    scanf("%s",str);
    x = convert_x(str);
    y = convert_y(str);
    replace(&a[x-1],&a[y-1]);
  }

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

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

int main()
{
	int n;
	cin >> n;
	int count = 0;
	for (int i = 1; i <= n; i++)
	{
		int temp = 0;
		for (int j = 1; j <= i; j++)
		{
			if (i%j == 0)
			{
				temp++;
			}
				
		}
		if (temp == 8 && i%2 == 1)
		{
			count++;
		}
	}
	cout << count << endl;
}


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

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int INF = 1000000009;
const int MAXN = 1000;

char tab[MAXN + 3][MAXN + 3];
int cnt[MAXN + 3], add[MAXN + 3];
int cuts[MAXN + 3];

int main(){
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    for(int i=0; i<n; i++)
        scanf("%s", tab[i]);
    int ans = INF;
    for(int mask = 0; mask < 1<<(n-1); mask++){
//         printf("%d:\n", mask);
        int cand = 0;
        for(int i=0; i<n-1; i++) cuts[i] = 0;
        for(int i=0; i<n; i++) cnt[i] = 0;
        for(int i=0; i<n-1; i++)
            if((1<<i) & mask){
                cuts[i] = 1;
                cand++;
            }
        for(int i=0; i<m; i++){
            for(int j=0; j<n; j++)
                add[j] = 0;
            bool inc = false;
            int sum = 0, sum2 = 0;
            for(int j=0; j<n; j++)
                add[j] = tab[j][i] - '0';
            for(int j=0; j<n; j++){
                sum += cnt[j] + add[j];
                sum2 += add[j];
                if(sum > k){
                        inc = true;
//                         puts("lol");
                        break;
                }
//                 printf("%d %d\n", sum, sum2);
                if(cuts[j]){
                    sum =  0;
                    sum2 = 0;
                }
            }
            
            if(inc){
                if(i==0 || sum2 > k){
                    cand = INF;
                    break;
                }
                cand ++;
                for(int j=0; j<n; j++)
                    cnt[j] = add[j];
            }
            else
                for(int j=0; j<n; j++)
                    cnt[j] += add[j];
        }
        
        ans = min(ans, cand);
//         printf("%d\n", ans);
    }
    
    printf("%d\n", ans);
    
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
const int INF = 100000000;

int main(){
  int n,m,s,g1,g2;
  while(cin>>n>>m>>s>>g1>>g2,n){
    s--;g1--;g2--;
    int d[100][100];
    REP(i,n)REP(j,n)d[i][j] = (i!=j)?INF:0;
    while(m--){
      int a,b,c;
      cin>>a>>b>>c;
      a--;b--;
      d[a][b] = c;
    }
    REP(k,n)REP(i,n)REP(j,n)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    int ans = INF;
    REP(i,n){
      ans = min(ans, d[s][i]+d[i][g1]+d[i][g2]);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long a[5],min=10,mini=0,ans=0;
    f(i,0,5){
        cin>>a[i];
        if(a[i]%10!=0&&a[i]%10<min){
            min=a[i]%10;
            mini=i;
        }
    }
    f(i,0,5){
        if(i!=mini){
            if(a[i]%10==0){
                ans+=a[i];
            }
            else{
                a[i]/=10;
                ans+=(a[i]+1)*10;
            }
        }
        else{
            ans+=a[mini];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;

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

    int a, b, k;
    cin >> a >> b >> k;

    int tarn = 1;
    REP(_, k)
    {
        //dump(tarn)
        if (tarn == 1)
        {
            if (a % 2 != 0){
                a -= 1;
                int exca = a / 2;
                //dump(exca)
                a -= exca;
                b += exca;
            }
            else{
                int exca = a / 2;
                //dump(exca)
                a -= exca;
                b += exca;
            }
        } else {
            if (b % 2 != 0){
                b -= 1;
                int excb = b / 2;
                //dump(excb)
                b -= excb;
                a += excb;
            } else {
                int excb = b / 2;
                //dump(excb)
                b -= excb;
                a += excb;
            }
        }

        tarn *= -1;
    }

    cout << a << " " << b;
   
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;
int h,w,n,i,j,z,s,x,y,a[104][104];
int main()
{
    scanf ("%d %d", &h, &w);
    scanf ("%d", &n);
    x=1;
    y=1;
    s=1;
    for (i=1;i<=n;i++)
    {
        scanf ("%d", &z);
        for (j=1;j<=z;j++)
        {
            a[x][y]=i;
            y+=s;
            if (y==(w+1))
            {
                x++;
                y=w;
                s=-1;
            }
            else if (y==0)
            {
                x++;
                y=1;
                s=1;
            }
        }
    }
    for (i=1;i<=h;i++)
    {
        for (j=1;j<=w;j++)
            printf ("%d ", a[i][j]);
        printf ("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;

signed main() {
  int N, aoki,taka;
  cin >> N >> taka >> aoki;
  
  Graph G(N);
  int A, B;
  for( int i = 0; i < N; i++ ){
    cin >> A >> B;
    G.at(A-1).push_back(B-1);
    G.at(B-1).push_back(A-1);
  }
  
  //青木君を根としてBFS
  vector<int> Adist(N, -1);
  queue<int> que;
  
  Adist.at(aoki-1) = 0;
  que.push(aoki-1);
  
  while( !que.empty() ){
    int v = que.front();
    que.pop();
    
    for( int nv : G.at(v) ){
      if( Adist.at(nv) != -1 ) continue;
      Adist.at(nv) = Adist.at(v)+1;
      que.push(nv);
    }
  }
  
  //高橋君から見てBFS
  vector<int> Tdist(N, -1);
  Tdist.at(taka-1) = 0;
  que.push(taka-1);
  
  while( !que.empty() ){
    int v = que.front();
    que.pop();
    
    for( int nv : G.at(v) ){
      if( Tdist.at(nv) != -1 ) continue;
      
      Tdist.at(nv) = Tdist.at(v) + 1;
      que.push(nv);
    }
  }
  
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    if( Tdist.at(i) < Adist.at(i) ){
      ans = max(ans, Adist.at(i));
    }
  }
  ans--;
  cout << ans << endl;
  
    
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>

using namespace std;


#define rep(i,x,y) for(int i = x; i <= y; ++i)
#define repr(i,x,y) for(int i = x; i >= y; --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define endl "\n" // TODO: remove
#define int long long

const int N = (int)(1e6) + 322;
const long long inf = (long long)(2e18) + 322;
const int mod = (int)(1e9) + 7; // check modulo

int a[N];

void solve() {
    int cnt = 0, n; cin >> n;
    rep(i, 1, n) {
        cin >> a[i];
    }
    rep(i, 1, n) {
        rep(j, i + 1, n) {
            rep(k, j + 1, n) {
                if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i] && a[i] != a[j] && a[i] != a[k] && a[k] != a[j]) {
//                    cout << i << ' ' << j << ' ' << k << endl;
                    cnt++;
                }
            }
        }
    }
    cout << cnt;
}

signed main () {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    int test = 1;//  cin >> test;
    for(int t = 1; t <= test; ++t) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3144
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;


int main(void)
{
	//変数の宣言
	int n;
	char s[100010];
	int alphabet[30];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	int ok,ng;
	int r;
	


	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);

/*	for(i=0;i<n;i++){
//		scanf("%d",&number[i].num);
		scanf_s("%d",&number[i].num);
		number[i].idnum=i;
		number[i].a=number[i].num;
	}*/
	
	scanf("%s",&s);
//	scanf_s("%s",&s,100010);

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理


	for(i=0;i<30;i++){
		alphabet[i]=1;
	}

	for(i=0;i<n;i++){
		alphabet[s[i]-'a']++;
	}

	ans=1;
	for(i=0;i<30;i++){
		ans=ans*alphabet[i];
		ans=ans%MOD;
	}

	//	printf("計算部分終了\n");

	//出力

	printf("%lld",ans-1);


	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 384
function Main(input) {
    const N = parseInt(input.shift())
    const X = parseInt(input.shift())
    const Ls = input.map(x => parseInt(x));

    var current = 0;
    var sum = 1;
    for (var i = 0; i < N; i++) {
        current += Ls[i];
        if(current <= X) {
            sum++;
        }
    }
    console.log(sum);
}

// 1行入力の場合
// Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

// 改行で分割
// Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));

// 改行・空白で分割
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 21064
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <bitset>

using namespace std;

bool jud(int i, int n, int atoz[])
{
  //case:: i < n/2
  if (i < n/2)
    return false;
  else {
    //1?????¨2????????¢???
    //suf ??¨???????\¨??°
    pair<int,int> top, sec;
    top = sec = make_pair(0,0);

    for (int j = 0; j < 26; j++) {
      if (atoz[j] > 0 && top.second <= atoz[j]) {
	sec = make_pair(top.first,top.second);
	top = make_pair(j,atoz[j]);
      }
      else if (atoz[j] > 0 && sec.second <= atoz[j]) {
	sec  = make_pair(j,atoz[j]);
      }
    }   
    //???????????§????\¨??????
    if (i == n-1) { 
      //1????????????
      if (top.second == sec.second) {
	cout << "TIE" << endl;
	return true;
      }
      //1????????????
      else {
	char c = top.first + 65;
	cout << c << " " << i+1 << endl;
	return true;
      }
    }
    //?????°???????\¨??????
    else {
      if (top.second > sec.second + n-1-i) {
	char c = top.first + 65;
	cout << c << " " << i+1 << endl;
	return true;
      }
    }
  }
  return false;
}

int main(void)
{
  int atoz[26];
 
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    char c[n];
    for (int i = 0; i < n; i++)
      cin >> c[i];
    memset(atoz, 0, sizeof(atoz));

    bool flag = false;
    for (int i = 0; i < n; i++) {
      atoz[c[i]-65]++;
      //true::decided
      flag = jud(i, n, atoz);
      if (flag)
	break;
    }
  }
  return 0;	
}

Measured memory_bytes: 3032
def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt, A

def shellSort(A, n):
    cnt = 0
    g = [1]
    while g[-1] * 3 + 1 < n:
        g.append(g[-1] * 3 + 1)
    g.reverse()
    print(len(g))
    print(' '.join([str(_g) for _g in g]))
    for i in range(len(g)):
        cnt, A = insertionSort(A, n, g[i], cnt)
    return cnt, A

def run():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(int(input()))
    cnt, ans = shellSort(A, n)
    print(cnt)
    print('\n'.join([str(a) for a in ans]))

if __name__ == '__main__':
    run()




Measured memory_bytes: 126056
w = int(input())
Ver = list(range(1, w+1))

n = int(input())

for i in range(n):
    j, k = map(int, input().split(','))

    temp = Ver[j-1]
    Ver[j-1] = Ver[k-1]
    Ver[k-1] = temp

for i in range(len(Ver)):
    print(Ver[i])

Measured memory_bytes: 7516
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>

using namespace std;

int main(int argc, const char * argv[]) {
        int N = 0;
        int max = 0;
        int min = 0;
        int count = 0;

        cin >> N;
        vector<int> p(N);
        for(int i=0; i<N; i++){
                cin >> p[i];
        } 

        for(int i=0; i<N; i++){
                if(p[i] != (i+1)){ count++;}
        }
        
        if(count < 3){ cout << "YES" << endl;}
        else{ cout << "NO" << 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 main() {
	int N;
	cin >> N;
	ll sum = 0;
	ll minB = INF;
	for (int i = 0; i < N; i++) {
		ll A, B;
		cin >> A >> B;
		sum += A;
		if (A > B) minB = min(minB, B);
	}
	if (minB == INF) cout << 0 << endl;
	else cout << sum - minB << endl;
}


Measured memory_bytes: 256
n,m,k=map(int,input().split())

def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

def same(x,y):
    return find(x) == find(y)

def size(x):
    return -par[find(x)]

par = [-1]*n

ans=[0]*n
nxt=[0]*n
block=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(int,input().split())
    unite(a-1,b-1)
    nxt[a-1]+=1
    nxt[b-1]+=1

for _ in range(k):
    c,d=map(int,input().split())
    block[c-1].append(d-1)
    block[d-1].append(c-1)

for i in range(n):
    ans[i]=size(i)-nxt[i]-1
    for j in block[i]:
        if same(j,i):
            ans[i]-=1
print(*ans)

Measured memory_bytes: 31872
#include <iostream>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const int MAXN = 200010;
const int MOD = 1e9+7;

int n;

ll A[MAXN], B[MAXN];

ll gcd(ll x, ll y) {
  if (x < y) {
    swap(x, y);
  }
  if (y == 0) {
    return x;
  }
  return gcd(y, x % y);
}

ll modPow(ll x, ll y) {
  ll res = 1;

  x = x % MOD;

  while (y > 0) {
    if (y & 1) {
      res = (res * x) % MOD;
    }
    y >>= 1;
    x = (x * x) % MOD;
  }
  return res;
}

void solve() {
  map<P, ll> m;
  int zeroCnt = 0;
  for (int i=0;i<n;i++) {
    ll d = gcd(abs(A[i]), abs(B[i]));
    if (d > 0) {
      A[i] /= d;
      B[i] /= d;
    }
    if (A[i] == 0 && B[i] == 0) {
      zeroCnt++;
      continue;
    }

    if (A[i] == 0 && B[i] != 0) {
      B[i] = 1;
    }
    if (A[i] != 0 && B[i] == 0) {
      A[i] = 1;
    }
    if (A[i] < 0) {
      A[i] *= -1;
      B[i] *= -1;
    }
    m[P(A[i], B[i])]++;
  }

  ll cnt = 0;
  ll comb = 1;
  for (auto& x : m) {
    P p = x.first;
    if (x.second > 0) {
      ll otherCnt = p.second > 0 ? m[P(p.second, -p.first)] : m[P(-p.second, p.first)];
      if (otherCnt > 0) {
        cnt += x.second + otherCnt;

        comb = comb * (modPow(2, x.second) + modPow(2, otherCnt) - 1) % MOD;
      }
      x.second = 0;
    }
  }
  ll ans = (comb * modPow(2, n - zeroCnt - cnt) + zeroCnt - 1 + MOD) % MOD;
  cout << ans << endl;
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> A[i] >> B[i];
  }
  solve();
}


Measured memory_bytes: 31756
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define lli long long int
#define pb push_back
#define mp make_pair
#define fo(i,n) for(i=0;i<(n);i++)
#define endl "\n"
#define mod 1000000007

long long int i,j;
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    lli n;
    cin>>n;
    lli a[n],b[n]={0};
    fo(i,n)cin>>a[i];
    b[0]=0;
    b[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        b[i]=min(abs(a[i]-a[i-1])+b[i-1],abs(a[i]-a[i-2])+b[i-2]);
    }
    cout<<b[n-1];
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] ab = scanner.nextLine().split(" ", 2);
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);

        if (Math.max(a, b) <= 8) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}


Measured memory_bytes: 23764
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using Moveset = vector<int>;

vector<Moveset> GetMovesets(const string &str)
{
    vector<Moveset> moves(str.size(), vector<int>(26, -1));
    for (int i = str.size() - 2; i >= 0; i -= 1) {
        copy(moves[i + 1].begin(), moves[i + 1].end(), moves[i].begin());
        moves[i][str[i + 1] - 'a'] = i + 1;
    }
    return moves;
}

Moveset GetFirsts(const string &str)
{
    Moveset first(26, -1);
    for (size_t i = 0; i < str.size(); i += 1) {
        if (first[str[i] - 'a'] == -1) {
            first[str[i] - 'a'] = i;
        }
    }
    return first;
}

int64_t Solve(const string &s, const string &t)
{
    auto moves = GetMovesets(s);
    auto first = GetFirsts(s);

    for (const auto &ch : t) {
        if (first[ch - 'a'] == -1) {
            return -1;
        }
    }

    int64_t res = 0;
    auto pos = 0;

    for (const auto &ch : t) {
        if (res == 0) {
            pos = first[ch - 'a'];
            res = pos + 1;
            continue;
        }

        if (moves[pos][ch - 'a'] == -1) {
            res += s.size() - pos - 1;
            pos = first[ch - 'a'];
            res += pos + 1;
        } else {
            res += moves[pos][ch - 'a'] - pos;
            pos = moves[pos][ch - 'a'];
        }
    }
    return res;
}

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

    auto res = Solve(s, t);
    cout << res << "\n";

    return 0;
}


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


class Program
{


    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        int n = sc.intarr[0];
        int[] a = new int[n+2];

        a[0] = 0;
        a[n + 1] = 0;

        int[] b = sc.intarr;
        for(int i = 1; i <= n; ++i)
        {
            a[i] = b[i - 1];
        }

        int sowa = 0;
        for(int i = 0; i < n + 1; ++i)
        {
            sowa += Math.Abs(a[i] - a[i + 1]);
        }

        for(int i = 1; i <= n; i++)
        {
            wr.wri(sowa + Math.Abs(a[i - 1] - a[i + 1]) - Math.Abs(a[i - 1] - a[i]) - Math.Abs(a[i] - a[i + 1]));
        }

    }


}
    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => strarr.Select(char.Parse).ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 28500
N=int(input())
A=list(map(int,input().split()))
ans=1
if 0 in A:
  print(0)
  ans=0
else:
  for i in range(N):
    ans=ans*A[i]
    if ans>10**18:
      print(-1)
      ans=0
      break
if ans!=0:
  print(ans)

Measured memory_bytes: 21776
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, a, t;
	cin >> n >> t >> a;
	double mini = 1e9;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		double y = (double)t - (double)x * 0.006;
		//cout << abs(y - a) << "\n\n";
		if(abs(y - a) < mini){
			mini = abs(((double)t - (double)x * 0.006) - a);
			ans = i + 1; 
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>
char s[5];
//模範回答
int main ()
{   
	scanf("%s",&s);
	int a=s[0]-'0', b=s[1]-'0', c=s[2]-'0', d=s[3]-'0'; 
 	if(a-b-c-d==7) printf("%d-%d-%d-%d=7\n",a,b,c,d);
	else if(a-b-c+d==7) printf("%d-%d-%d+%d=7\n",a,b,c,d); 
  	else if(a-b+c-d==7) printf("%d-%d+%d-%d=7\n",a,b,c,d); 
  	else if(a-b+c+d==7) printf("%d-%d+%d+%d=7\n",a,b,c,d); 
  	else if(a+b-c-d==7) printf("%d+%d-%d-%d=7\n",a,b,c,d); 
  	else if(a+b-c+d==7) printf("%d+%d-%d+%d=7\n",a,b,c,d); 
  	else if(a+b+c-d==7) printf("%d+%d+%d-%d=7\n",a,b,c,d); 
    else if(a+b+c+d==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
}

Measured memory_bytes: 1716
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		StringBuilder ss = new StringBuilder();
		
		for(int i=0;i<s.length();i++){
			char c = s.charAt(i);
			if(c == '1'){
				ss.append("1");
			}if(c == '0'){
				ss.append("0");
			}if(c == 'B' && ss.length() > 0){
				//ss.replace(ss.length()-1, ss.length(), "");
				ss.deleteCharAt(ss.length()-1);
			}
		}
		System.out.println(ss);
	}
}


Measured memory_bytes: 8916
package main

import (
    "fmt"
)

func main() {
    var x int
    fmt.Scanf("%d", &x)
    ans := false
    for x > 0 {
        if x % 10 == 9 {
            ans = true
        }
        x = x / 10
    }

    if ans {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
const long long mod = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int a = s[0] - '0';
	int b = s[1] - '0';
	int c = s[2] - '0';
	int d = s[3] - '0';
	if (a + b + c + d == 7)cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
	else if (a - b + c + d == 7)cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
	else if (a + b - c + d == 7)cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
	else if (a + b + c - d == 7)cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl; 
	else if (a - b - c + d == 7)cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
	else if (a - b + c - d == 7)cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
	else if (a + b - c - d == 7)cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
	else if (a - b - c - d == 7)cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
const int maxn = 305;

int a[5];
double dp[maxn][maxn][maxn];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	rep(i, n){
		int x;
		cin >> x;
		a[x - 1]++;
	}
	double p = 1.0 / n;
	rep(k, n + 1) rep(j, n + 1) rep(i, n + 1){
		int z = n - i - j - k;
		if(z < 0) break;
		if(z == n) continue;
		if(i) dp[i][j][k] += dp[i - 1][j][k] * p * i;
		if(j) dp[i][j][k] += dp[i + 1][j - 1][k] * p * j;
		if(k) dp[i][j][k] += dp[i][j + 1][k - 1] * p * k;
		double x = 1 - z * p;
		dp[i][j][k] += 1;
		dp[i][j][k] /= x;
	}
	cout << setprecision(10) << dp[a[0]][a[1]][a[2]] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 219392
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int n,d;
	cin>>n>>d;
	vector<int> x(n*d);
	rep(i,n*d) cin>>x[i];
	int sum=0,cnt=0;
	int sqr;
	for (int i=1;i<n;i++){
		for(int j=0;j<i;j++){
			sum=0;
			rep(k,d){
				sum+=(x[i*d+k]-x[j*d+k])*(x[i*d+k]-x[j*d+k]);
			}
			sqr=floor(sqrt(sum));
			if(sum==sqr*sqr) cnt++;
		}
	}
	cout<<cnt<<endl;




	return 0;
}

Measured memory_bytes: 256