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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;


#define pb push_back
#define ff first
#define ss second
#define INF int(3e9)
#define BIG_INF ll(9e18)
#define SIZE 100001
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define len(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)
#define filein freopen("input.txt", "r", stdin)
#define fileout freopen("output.txt", "w", stdout);


ll binpow(ll a, ll b, ll MOD = BIG_INF)
{
    ll res = 1;

    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= MOD;
        res %= MOD;
    }

    return res % MOD;
}

const ll mod = 1e9 + 7;


int T = 1;
int n, m;

ll h[SIZE], p[SIZE];
vector<int> g[SIZE];

vector<int> cnt, nxt;


bool OK = 1;


void dfs(int u, int pr, int kGood, int kBad)
{
    for(int v: g[u])
    {
        if(v == pr) continue;

        int good = 0, bad = 0;

        good = cnt[v] + h[v];
        good = (good + 1) / 2;
        bad = cnt[v] - good;
//        cout << good << ' ' << bad << '\n';
        if(good < 0 || bad < 0 || good - bad != h[v])
        {
            OK = 0;
            return;
        }
        kBad -= bad;
        kGood -= good;

        if(kGood < 0)
        {
            OK = 0;
            return;
        }


        if(kBad < 0)
        {
            int d = abs(kBad);
            if(d > kGood)
            {
                OK = 0;
                return;
            }
            kGood -= d;
            kBad = 0;
        }
//        cout << v << " " << good << ' ' << bad << " " << kGood << ' ' << kBad << "\n";
        dfs(v, u, good, bad);

    }

    if(kGood + kBad != p[u])
    {
        OK = 0;
    }
}

void calc(int u, int pr)
{
    for(int v: g[u])
    {
        if(v != pr)
        {
            calc(v, u);
            cnt[u] += cnt[v];
        }
    }

    cnt[u] += p[u];
}


void solve()
{
    int x;
    cin >> x;

    if(x <= 599) cout << '8';
    else if(x <= 799) cout << '7';
    else if(x <=  999) cout << '6';
    else if(x <= 1199) cout << "5";
    else if(x <= 1399) cout << "4";
    else if(x <= 1599) cout << '3';
    else if(x <= 1799) cout << '2';
    else cout << 1;
    return;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
//    filein;fileout;

//    cin >> T;
//
    while(T--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5956
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int64_t x,y;
  cin>>x>>y;
  int64_t sum=99999999999;
  if(y>=x){sum=min(sum,y-x);}
  if(-y>=x){sum=min(sum,-y-x+1);}
  if(y>=-x){sum=min(sum,y+x+1);}
  if(-y>=-x){sum=min(sum,-y+x+2);}
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3636
A, B, C, D = map(int, input().split())
cnt_1 = 0
cnt_2 = 0

while A >= 1:
    A = A - D
    cnt_1 += 1
    
while C >= 1:
    C = C - B
    cnt_2 += 1
    
if cnt_1 >= cnt_2:
    print('Yes')
else:
    print('No') 

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
void solve()
{
    int n;
    cin >> n;
    int a = n / 1000;
    if(n%1000)
    a++;
    a *= 1000;
    cout << a - n << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define watch(x) cerr << (#x) << " is " << (x) << " ";

using namespace std;

vector<pair<long long, long long>> positions;
vector<long long> distances;

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, -1, 1};
char dc[4] = {'L', 'R', 'U', 'D'};
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	
	long long int min_total_length = 0;
	long long int x, y;
	for (int i = 0; i < n; i++){
		cin >> x >> y;
		positions.push_back(make_pair(x, y));
		distances.push_back(abs(x) + abs(y));
		min_total_length = max(min_total_length, abs(x) + abs(y));
	}
	//cerr << min_total_length << '\n';
	int parity = min_total_length % 2;
	for (auto d : distances){
		if (d % 2 != parity){
			cout << -1 << endl;
			return 0;
		}
	}
	
	/* //dumb solution
	cout << min_total_length << endl;
	for (int i = 0; i < min_total_length; i++){
		cout << 1;
		if (i != min_total_length - 1){
			cout << ' ';
		}
	}
	cout << endl;
	
	//find the shortest path, and then extend to the right, and back left as needed
	for (auto loc : positions){
		int x = loc.first; int y = loc.second;
		for (int i = 0; i < abs(x); ++i){
			if (x > 0) {
				cout << 'R';
			}
			else{
				cout << 'L';
			}
		}
		for (int i = 0; i < abs(y); ++i){
			if (y > 0) {
				cout << 'U';
			}
			else{
				cout << 'D';
			}
		}
		for (int i = 0; i < min_total_length - abs(x) - abs(y); i++){
			if (i % 2 == 0){
				cout << 'R';
			}
			else{
				cout << 'L';
			}
		}
		cout << '\n';
	} */
	//smart solution
	int size = 32 - parity;
	vector<long long> lengths;
	cout << size << endl;
	
	int start = 1;
	if (parity == 0){
		lengths.push_back(start);
		cout << start << ' ';
	}
	for (int i = 0; i < 31; i++){
		lengths.push_back(start);
		cout << start; if (i != 30) cout << ' ';
		start *= 2;
	}
	cout << endl;
	
	reverse(lengths.begin(), lengths.end());
	vector<char> directions;
	for (auto loc : positions){
		long long x = loc.first, y = loc.second;
		for (long long i : lengths){
			int remaining_length = i - parity;
			for (int j = 0; j < 4; j++){
				if (abs(x + dx[j] * i) + abs(y + dy[j] * i) <= remaining_length){
					x = x + dx[j] * i; y = y + dy[j] * i;
					directions.push_back(dc[j]);
					break;
				}					
			}
		}
		
		reverse(directions.begin(), directions.end());
		for (char c : directions){
			cout << c;
		}
		cout << endl;
		directions.clear();
	}
	
	
	return 0;
}


Measured memory_bytes: 384
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXN 128
#define MAXT 128

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int field[MAXN];
double dp[MAXT][MAXN];

int main(void) {
    int N, T, L, B;
    while (1) {
        cin >> N >> T >> L >> B;
        if (N == 0 && T == 0 && L == 0 && B == 0) break;
        // fieldが0だと特に何も起こらない
        for (int i = 0; i <= N; i++) field[i] = 0;
        // fieldが1だと1回休み
        vector<int> yasumi;
        for (int i = 0; i < L; i++) {
            int l;
            cin >> l;
            field[l] = 1;
            yasumi.push_back(l);
        }
        // fieldが2だとスタートに戻る
        for (int i = 0; i < B; i++) {
            int b;
            cin >> b;
            field[b] = 2;
        }
        // DP 準備
        for (int t = 1; t <= T; t++) {
            for (int n = 0; n <= N; n++) {
                dp[t][n] = 0;
            }
        }
        dp[0][0] = 1;
        // DP
        for (int t = 1; t <= T; t++) {
            for (int n = 0; n < N; n++) {
                // 基本
                for (int i = 1; i <= 6; i++) {
                    int next;
                    if (n + i <= N) next = n + i;
                    else next = N - (n + i - N);
                    if (field[next] == 2) {
                        dp[t][0] += dp[t-1][n] / 6;
                    } else if (field[next] == 1) {
                        if (t < T) {
                            dp[t+1][next] += dp[t-1][n] / 6;
                        }
                    } else {
                        dp[t][next] += dp[t-1][n] / 6;
                    }
                }
            }
        }
        double ans = 0;
        for (int i = 0; i <= T; i++) {
            ans += dp[i][N];
        }
        printf("%.10f\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1340
K=int(input())
if K % 2 == 0:
    print(-1)
    exit()

m = set()
x = 7
ans = 1
while x > 0:
    if x < K:
        x = x*10 + 7
        ans += 1
    x = x % K
    if x in m:
        print(-1)
        exit(0)
    else:
        m.add(x)

print(ans)


Measured memory_bytes: 77940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

namespace PaizaSkillCheck
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            List<Dish> dishList = new List<Dish>(n);
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Split(' ');

                dishList.Add(new Dish(long.Parse(line[0]), long.Parse(line[1])));
            }

            var ary = dishList.OrderByDescending(x => x.sum).ToArray();

            BigInteger p = 0;

            for (int i = 0; i < n; i++)
            {
                if (i % 2 == 0)
                {
                    p += ary[i].takahashi;
                }
                else
                {
                    p -= ary[i].aoki;
                }
            }

            Console.WriteLine(p);
            Console.ReadLine();
        }

        public class Dish
        {
            public long takahashi;
            public long aoki;
            public long sum;

            public Dish(long takahashi, long aoki)
            {
                this.takahashi = takahashi;
                this.aoki = aoki;
                this.sum = takahashi + aoki;
            }
        }
    }

}


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

#define MOD (1000000000+7)

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

	int N = S.size();
	vector<vector<long long>> dp( N + 1, vector<long long>( 13 ) );
	dp[0][0] = 1;
	for( int i = 0; i < N; i++ ) {
		if( S[i] != '?' ) {
			int n = S[i] - '0';
			for( int k = 0; k < 13; k++ ) {
				dp[i + 1][( k * 10 + n ) % 13] += dp[i][k];
				dp[i + 1][( k * 10 + n ) % 13] %= MOD;
			}
		}
		else {
			for( int j = 0; j < 10; j++ ) {
				for( int k = 0; k < 13; k++ ) {
					dp[i + 1][( k * 10 + j ) % 13] += dp[i][k];
					dp[i + 1][( k * 10 + j ) % 13] %= MOD;
				}
			}
		}
	}
	long long ans = dp[N][5];

	cout << ans << endl;
}


Measured memory_bytes: 13696
import math
[A, B] = list(map(int, input().split()))
flag = False
for i in range(1001):
  if math.floor(i*0.08) == A and math.floor(i*0.1) == B:
    ans = i
    flag = True
    break

if flag:
  print(ans)
else:
  print(-1)

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

#define XMAX 5000
#define YMAX 5000

char p[5001][5001];
int x[3000];
int y[3000];

int main(void) {
    int n, i, j, gx, gy, max_area, area, x2, y2, x3, y3, k;

    while (scanf("%d", &n) != EOF && n) {
        memset(p, 0, sizeof(p));
        for (i = 0; i < n; i++) {
            scanf("%d%d", &x[i], &y[i]);
            p[y[i]][x[i]] = 1;
        }
        for (i = 0, max_area = 0; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                gx = x[j] - x[i];
                gy = y[j] - y[i];
                for (k = -1; k <= 1; k += 2) {
                    x2 = x[i]+ k * gy;
                    y2 = y[i]- k * gx;
                    x3 = x[i]+gx+ k * gy;
                    y3 = y[i]+gy- k * gx;
                    if (0 <= x2 && x2 <= XMAX && 0 <= y2 && y2 <= YMAX &&
                        0 <= x3 && x3 <= XMAX && 0 <= y3 && y3 <= YMAX &&
                        p[y2][x2] && p[y3][x3]) {
                        area = gx * gx + gy * gy;
                        if (max_area < area) max_area = area;
                    }
                }
            }
        }
        printf("%d\n", max_area);
    }
    return 0;
}

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

int main(){
	int N, M, Q, x1, y1, x2, y2, i, j;
	scanf("%d%d%d", &N, &M, &Q);
	int **S = (int **)malloc(sizeof(int *) * (N + 1));
	for(i = 0; i <= N; i++){
		S[i] = (int *)malloc(sizeof(int) * (M + 1));
		for(j = 0; j <= M; j++){
			if(i > 0 && j > 0){
				scanf("%1d", &S[i][j]);
			}
			else{
				S[i][j] = 0;
			}
		}
	}
	int **joge = (int **)malloc(sizeof(int *) * (N + 1));
	for(i = 0; i <= N; i++){
		joge[i] = (int *)malloc(sizeof(int) * (M + 1));
		for(j = 0; j <= M; j++){
			if(i < N){
				joge[i][j] = (S[i][j] & S[i + 1][j]);
			}
		}
	}
	int **sayu = (int **)malloc(sizeof(int *) * (N + 1));
	for(i = 0; i <= N; i++){
		sayu[i] = (int *)malloc(sizeof(int) * (M + 1));
		for(j = 0; j <= M; j++){
			if(j < M){
				sayu[i][j] = (S[i][j] & S[i][j + 1]);
			}
		}
	}
	for(i = 1; i <= N; i++){
		for(j = 0; j <= M; j++){
			S[i][j] += S[i - 1][j];
			if(i < N){
				joge[i][j] += joge[i - 1][j];
			}
			if(j < M){
				sayu[i][j] += sayu[i - 1][j];
			}
		}
	}
	for(i = 0; i <= N; i++){
		for(j = 1; j <= M; j++){
			S[i][j] += S[i][j - 1];
			if(i < N){
				joge[i][j] += joge[i][j - 1];
			}
			if(j < M){
				sayu[i][j] += sayu[i][j - 1];
			}
		}
	}
	int *ans = (int *)malloc(sizeof(int) * Q);
	for(i = 0; i < Q; i++){
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		x1--;
		y1--;
		ans[i] = 0;
		ans[i] += S[x2][y2] - S[x1][y2] - S[x2][y1] + S[x1][y1];
		ans[i] -= joge[x2 - 1][y2] - joge[x1][y2] - joge[x2 - 1][y1] + joge[x1][y1];
		ans[i] -= sayu[x2][y2 - 1] - sayu[x1][y2 - 1] - sayu[x2][y1] + sayu[x1][y1];
	}
	for(i = 0; i < Q; i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}

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


int main(){
    cin >> s;
    int n=s.size()+1;
    long long int a[n]={};
    for(int i=0; i<n-1; i++){
        if(s[i]=='<')a[i+1]=a[i]+1;
    }
    for(int i=n-2; i>=0; i--){
        if(s[i]=='>'){
            int tmp=max(a[i],a[i+1]+1);
            a[i]=tmp;
        }
    }

    long long int sum=0;

    for(int i=0; i<n; i++){
        //cout << a[i] << "!";
        sum+=a[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 4740
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

struct Pos {
  ll x, y;

  bool operator< (const Pos& other) const {
    return (x == other.x ? y < other.y : x < other.x);
  }
};

inline ll cross(Pos &a, Pos &b, Pos &c) {
  return (((b.x - a.x) * (c.y - a.y)) - ((b.y - a.y) * (c.x - a.x)));
}

void convex_hull(vector<Pos> &ps, vector<Pos> &qs) {
  qs.clear();
  qs.reserve(ps.size());
  int n = ps.size();
  for(auto p : ps) {
    while(qs.size() > 1 && cross(qs[qs.size()-2], qs[qs.size()-1], p) > 0) {
      qs.pop_back();
    }
    qs.push_back(p);
  }
  int t = qs.size();

  for(int i = n-2; i >= 0; --i) {
    Pos &p = ps[i];
    while(qs.size() > t && cross(qs[qs.size()-2], qs[qs.size()-1], p) > 0) {
      qs.pop_back();
    }
    qs.push_back(p);
  }
  qs.pop_back();
}

int main() {
  int n;
  vector<Pos> ps, qs;
  cin >> n;
  rep(i, n) {
    int x, y; cin >> x >> y;
    ps.emplace_back(Pos{y, x});
  }
  sort(ALL(ps));
  convex_hull(ps, qs);
  cout << qs.size() << endl;
  repe(&q, qs) {
    cout << q.y << " " << q.x << endl;
  }
  return 0;
}


Measured memory_bytes: 6708
#include<cstdio>
#include<algorithm>
using namespace std;

int rows[10001],cols[10001];
bool okr[10001],okc[10001];

int main() {
  int n;
  while(scanf("%d", &n), n) {
    for(int i=0; i<n; ++i) scanf("%d", rows+i);
    for(int i=0; i<n; ++i) scanf("%d", cols+i);

    sort(rows, rows+n);
    sort(cols, cols+n);
    int csize = n,rsize = n;
    int front = 0,back = n-1;
    while(1) {
      int pf = front,pb = back;
      while(rows[back] == rsize) {
	//printf("fill : %d\n", back);
	csize--;
	for(int i=front; i<n; ++i) cols[i]--;
	back--;
	if(back == -1) break;
      }

      while(cols[front] == 0) {
	//printf("skiped : %d\n", front);
	rsize--;
	front++;
	if(front == n || back == -1) goto END;
      }
      if(pf == front && pb == back) break;
    }

  END:;

    for(int i=0; i<n; ++i) {
      if(cols[i] > 0) {
	printf("No\n");
	goto NEXT;
      }
    }
    printf("Yes\n");
  NEXT:;
  }
}

Measured memory_bytes: 808
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long T = sc.nextInt();
		long t[] = new long[N];
		for(int i = 0; i < N; i++) {
			t[i] = sc.nextInt();
		}
		
		long ans = 0;
		for(int i = 0; i < N - 1; i++) {
			if(t[i + 1] - t[i] >= T) {
				ans += T;
			} else {
				ans += t[i + 1] - t[i];
			}
		}
		ans += T;
		System.out.println(ans);
	}
}


Measured memory_bytes: 91804
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    long long N;
    cin >> N;
    long long minimum = N - 1;
    for (int i = 1; i <= 1000000; i++) {
        if (N % i == 0) {
            minimum = min(minimum, i + N / i - 2);
        }
    }
    cout << minimum << endl;
    return 0;
}


Measured memory_bytes: 256
use std::cmp;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn find_min(x: &[u64]) -> u64 {
    let mut min: u64 = x[0];
    let mut x_iter = x.iter();
    while let Some(i) = x_iter.next() {
        min = cmp::min(*i, min);
    }
    return min;
}

#[allow(dead_code)]
fn find_max(x: &[u64]) -> u64 {
    let mut max: u64 = x[0];
    let mut x_iter = x.iter();
    while let Some(i) = x_iter.next() {
        max = cmp::max(*i, max);
    }
    return max;
}
fn main() {
    let init: String = read();
    let s: Vec<char> = init.chars().collect();
    let s_num: Vec<u64> = s.iter().map(|&x| x as u64 - 48).collect();

    let mut diff: Vec<u64> = Vec::new();
    for i in 0..s_num.len() - 2 {
        let tmp: u64 = s_num[i as usize] * 100 + s_num[i + 1 as usize] * 10 + s_num[i + 2 as usize];
        if tmp >= 753 {
            diff.push(tmp - 753);
        } else {
            diff.push(753 - tmp);
        }
    }

    println!("{}", find_min(&diff));
}


Measured memory_bytes: 4352
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
		if A[i]%2 == 0 {
			if !(A[i]%3 == 0 || A[i]%5 == 0) {
				fmt.Println("DENIED")
				return
			}
		}
	}
	fmt.Println("APPROVED")
}


Measured memory_bytes: 512
S = input()
aindex = -1
for i in range(0, len(S)):
	if S[i] == 'A':
		aindex = i
		break
zindex = -1
for i in range(0, len(S)):
	if S[-1-i] == 'Z':
		zindex = len(S)-1-i
		break
print(zindex-aindex+1)

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

int main()
{
  ll n, sum = 0;
  map<ll, ll> mp;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    ll x;
    cin >> x;
    sum += x;
    mp[x]++;
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++)
  {
    ll b, c;
    cin >> b >> c;
    sum -= mp[b] * b;
    sum += mp[b] * c;
    mp[c] += mp[b];
    mp.erase(b);

    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 7536
/*
 * aoj/dpl_5_d/main.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/* Mod */
#define MOD 1000000007
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%MOD+MOD)%MOD){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%MOD+MOD)%MOD; return *this;}
  mint operator-() const { return mint(0) - *this;}
  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;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
ostream & operator << (ostream & out, mint const & v) {
  out << v.x;
  return out;
}

/* nCk */
template<class T> struct BiCoef {
    vector<T> fact_, inv_, finv_;
    constexpr BiCoef() {}
    constexpr BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) {
        init(n);
    }
    constexpr void init(int n) noexcept {
        fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);
        for(int i = 2; i < n; i++){
            fact_[i] = fact_[i-1] * i;
            inv_[i] = -inv_[MOD%i] * (MOD/i);
            finv_[i] = finv_[i-1] * inv_[i];
        }
    }
    constexpr T com(int n, int k) const noexcept {
        if (n < k || n < 0 || k < 0) return 0;
        return fact_[n] * finv_[k] * finv_[n-k];
    }
    constexpr T fact(int n) const noexcept {
        if (n < 0) return 0;
        return fact_[n];
    }
    constexpr T inv(int n) const noexcept {
        if (n < 0) return 0;
        return inv_[n];
    }
    constexpr T finv(int n) const noexcept {
        if (n < 0) return 0;
        return finv_[n];
    }
};

// n+k-1Cn
int N, K;
void solve() {
  cin >> N >> K;
  BiCoef<mint> bc;
  bc.init(2001);
  cout << bc.com(N+K-1, N) << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}



Measured memory_bytes: 3156
import numpy as np
h, w = map(int, input().rstrip("\n").split())

array = np.array([[" "] * (w + 2)] + [list(" " + input().rstrip("\n") + " ") for _ in range(h)] + [[" "] * (w + 2)])

def solve():
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if array[i][j] == "#":
                if "#" in array[i - 1][j] + array[i + 1][j] + array[i][j - 1] + array[i][j + 1]:
                    continue
                else:
                    return "No"
    return "Yes"

print(solve())


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

signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	cout.tie(nullptr);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int cnt=0;
	rep(i,s.size()/2)if(s[i]!=s[s.size()-i-1])cnt++;
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int min = 31,i,n,k,a;  
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a;
        k=0;
        while(a%2==0){
            k++;
            a /= 2;
        }
        if(k<min) min = k;
    } 
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
while not (h == 0 and w == 0):
    for i in range(h):
        s = ""
        for j in range(w):
            if (i+j) % 2 == 0:
                s = s + "#"
            else:
                s = s + "."
        print(s)
    print("")
    h, w = map(int, input().split())


Measured memory_bytes: 5608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>

/* choose a proper prime for the size of array (https://planetmath.org/goodhashtableprimes) */
static const int NMAX = 1572869;
static const int LMAX = 14;

void InsertValue(char (*charArr)[LMAX], char *targetCharArr);
long long GetHashCode(char *targetCharArr);
int GetIntToChar(char ch);
bool FindValue(char (*charArr)[LMAX], char *targetCharArr);

int main(){
    char dic[NMAX][LMAX], cmd[12], charArr[LMAX];
    int n;

    /* initialize the char array */
    for (int i = 0; i < NMAX; i++) {
        for(int j = 0; j < LMAX; j++) {
            dic[i][j] = '\0';
        }
    }
    
    std::cin >> n;

    for (int i = 0; i < n; i++) {
        scanf("%s %s", cmd, charArr);

        if (cmd[0] == 'i') {
            InsertValue(dic, charArr);
        } else if (cmd[0] == 'f') {
            if (FindValue(dic, charArr)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        } else {
            std::cerr << "ERROR! Invalid command.\n";
        }
    }

    return 0;
}

void InsertValue(char (*charArr)[LMAX], char *targetCharArr) {
    long long code;
    long entryIndex;

    code = GetHashCode(targetCharArr);
    for (int i = 0; i < NMAX; i++) {
        entryIndex = (code % NMAX + i * (1 + code % (NMAX - 1))) % NMAX;

        if (strcmp(charArr[entryIndex], targetCharArr) == 0) {
            // std::cerr << "WARNING! String " << targetCharArr << " is already in the array.\n";
            return;
        } else if(strlen(charArr[entryIndex]) == 0) {
            // std::cout << targetCharArr << ": " << entryIndex << std::endl;
            strcpy(charArr[entryIndex], targetCharArr);
            break;
        }
    }
}

long long GetHashCode(char *targetCharArr) {
    long long sum;
    int p;

    p = 0;
    sum = 0;

    for (int i = 0; i < strlen(targetCharArr); i++) {
        sum += GetIntToChar(targetCharArr[i]) * (int) pow(4, p++);
    }
    
    return sum;
}

int GetIntToChar(char ch) {
    if (ch == 'A') {
        return 0;
    } else if (ch == 'C') {
        return 1;
    } else if (ch == 'G') {
        return 2;
    } else if (ch == 'T') {
        return 3;
    } else {
        std::cerr << "ERROR! Invalid character " << ch << ".\n";
        exit(-1);
    }
}

bool FindValue(char (*charArr)[LMAX], char *targetCharArr) {
    long long code;
    long entryIndex;

    code = GetHashCode(targetCharArr);
    for (int i = 0; i < NMAX; i++) {
        entryIndex = (code % NMAX + i * (1 + code % (NMAX - 1))) % NMAX;

        if (strcmp(charArr[entryIndex], targetCharArr) == 0) {
            return true;
        } else if(strlen(charArr[entryIndex]) == 0) {
            return false;
        }
    }
    return false;
}


Measured memory_bytes: 24848
// abc project main.go
package main

import (
	"fmt"
)

func main() {
	var o string
	var e string
	fmt.Scan(&o)
	fmt.Scan(&e)

	for i := 0; i < len(e); i++ {
		fmt.Printf("%c", o[i])
		fmt.Printf("%c", e[i])
	}
	if len(o) > len(e) {
		fmt.Printf("%c", o[len(o)-1])
	}

	fmt.Println("")
}


Measured memory_bytes: 512
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] * N
for i in range(N-2, max(N-K-1, -1), -1):
    dp[i] = abs(h[N-1]-h[i])
if N > K + 1:
    for i in range(N-K-1, -1, -1):
        m = 10 ** 10
        for j in range(i+K, i, -1):
            m = min(m, abs(h[i]-h[j])+dp[j])
        dp[i] = m
print(dp[0])

Measured memory_bytes: 52448
#include <stdio.h>

#define N 100

void matrixChainOrder();

int num, p[N];

int main(){
  int i;

  scanf("%d", &num);

  for(i = 0; i < num; i++){
    scanf("%d %d", &p[i], &p[i+1]);
  }
  num++;
  
  matrixChainOrder();
  
  return 0;
}

void matrixChainOrder(){
  int n, k, l, i, j, q;
  int m[N][N] = {0};
  
  n = num-1;

  for(i = 1; i < n+1; i++){
    m[i][i] = 0;
  }
  
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n-l+1; i++){
      
      j = i+l-1;
      m[i][j] = 2100000000;
      
      for(k = i; k < j; k++){
	q = m[i][k] + m[k+1][j] + (p[i-1]) * (p[k]) * (p[j]);
	if(m[i][j] > q){
	  m[i][j] = q;
	}
      }
      
    }
  }

  printf("%d\n", m[1][n]);
 
}



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

signed main(){
	int n,k,l[50],ans = 0;
	cin >> n >> k;
	for(int i = 0;i < n;i++) cin >> l[i];
	sort(l,l + n,greater<int>());
	for(int i = 0;i < k;i++) ans += l[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
hs = list(map(int, input().split()))

costs = list(map(lambda h: abs(h - hs[0]), hs[:K]))
for i in range(K, N):
    costs.append( min( costs[i-j-1] + abs(hs[i-j-1] - hs[i]) for j in range(K) ) )
    
print(costs[-1])


Measured memory_bytes: 58848
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
	int k = 0;

	if(x > y) k = a * (x - y);
	else if(x < y) k = b * (y - x);

	cout << min(min(a * x + b * y, c * min(x, y) * 2 + k), max(x, y) * c * 2) << endl;
}

Measured memory_bytes: 256
main(c,t){double*p=t,v;for(;t=c&2&&printf("%f \n",v),~scanf("%s%c",&t,&c);)v=t<48?*--p=t&1?t&2?t&4?*p/v:*p+v:*p-v:*p*v:(*++p=atoi(&t));}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
  io;
  string n;
  ll i,ans=0;
  cin>>n;
  for(i=0;n[i]!=0;i++)
  {
    ans=ans+(n[i]-'0');
  }
  // cout<<ans;
  if(ans%9==0)
  cout<<"Yes\n";
  else
  cout<<"No\n";
  return 0;
}


Measured memory_bytes: 3776
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    edge = [[] for _ in range(N+1)]
    cnt = [0] * (N+1)
    for i in range(2,N+1):
        u = NI()
        edge[i].append(u)
        cnt[u] += 1

    q = collections.deque()
    for i in range(2,N+1):
        if cnt[i] == 0:
            q.append((i,0))
            cnt[i] = 1


    out = [[] for _ in range(N+1)]
    ret = 0
    while q:
        u,d = q.popleft()
        out[u].append(d)
        if len(out[u]) == cnt[u]:
            out[u].sort(reverse=True)
            ret = 0
            for i,x in enumerate(out[u]):
                ret = max(ret,i+x+1)
            if u == 1: break
            for v in edge[u]:
                q.append((v,ret))


    print(ret-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 103808
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <bitset>
#include <time.h>

using namespace std;
typedef long long  ll;
static const int M = 100000;
#define rep(i,s,n)for(int i = s;i<n;i++)

#include <fstream>

int main()
{
	int N, M; cin >> N >> M;
	cout << ((N - M) * 100 + 1900 * M) * (2 << (M-1)) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int a[200000],b[200000];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int N;
	cin >> N;
	for(int i=0; i<N; i++) cin >> a[i];

	int l = 0;
	int r = N-1;
	for(int i=N-1; i>=0; i--){
		if((N-1-i)%2 == 0){
			b[l] = a[i];
			l++;
		}
		else{
			b[r] = a[i];
			r--;
		}
	}

	for(int i=0; i<N; i++){
		if(i != 0) cout << " ";
		cout << b[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>
#include<string.h>
int main()
{
long int a,b,c=0,d=0,w=0,i,str1=0,str2=0,flag,j,count=0,k,n,sum=0;
char s[101],s2[101],s3[101];
scanf("%s %s %s",s,s2,s3);
printf("%c%c%c",s[0],s2[0],s3[0]);
 return 0;
}

Measured memory_bytes: 128
use v5.10;
use List::Util qw/max min/;

sub f {
  my ($a, $b, $dummy) = @_;
  my $la = length $a;
  my $lb = length $b;
  return max($la, $lb);
}

my $n = <>; chomp($n); # N
my $l = 11;            # result(l: length)

#say join(" ", ($n, $l)); # debug

for (my $i = 1; $i <= sqrt $n; $i++) {

  #say $i if ($i % 10000 == 0); # debug

  $q = $n / $i;
  $r = $n % $i;
  if ($r == 0) {
    $lf = f($i, $q);
    $l = min($l, $lf);
  }
}
say $l;


Measured memory_bytes: 640
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] texts = Console.ReadLine().Split(' ');
      	string[] input = Console.ReadLine().Split(' ');
		int text1Num = int.Parse(input[0]);
		int text2Num = int.Parse(input[1]);

		string text = Console.ReadLine();
      
        if (texts[0].Equals(text)) {
          text1Num -= 1;
        }
        else {
          text2Num -= 1;
        }
      	
      	Console.WriteLine(text1Num + " " + text2Num);
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <string>
using namespace std;

int main(){
	string a, b, c;
	char tmp[101];
	scanf("%s", tmp);
	a = tmp;
	scanf("%s", tmp);
	b = tmp;
	scanf("%s", tmp);
	c = tmp;

	int aa = 0, bb = 0, cc = 0;
	string turn = "a";
	string ans;
	while(1){
		if(turn == "a"){
			if(aa == a.size()){
				ans = "A";
				break;
			}else{
				turn = a[aa];
				aa++;
			}
		}else if(turn == "b"){
			if(bb == b.size()){
				ans = "B";
				break;
			}else{
				turn = b[bb];
				bb++;
			}
		}else{
			if(cc == c.size()){
				ans = "C";
					break;
			}else{
				turn = c[cc];
				cc++;
			}
		}
	}
	printf("%s\n", ans.c_str());
	return 0;
}

Measured memory_bytes: 256
n = int(input())
rr = [0 for _ in range(n)]
rrr = 0

for i in range(n):
    for k in reversed(range(i + 1)):
        if (i + 1) % (k + 1) == 0:
            rr[i] += 1

    if (i + 1) % 2 != 0 and rr[i] == 8:
        rrr += 1

print(rrr)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}


void solve(void){
    int r;
    cin>>r;
    if(r < 1200)cout << "ABC";
    else if(r < 2800) cout << "ARC";
    else cout << "AGC";
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int n, m;
  cin >> n >> m;
  V<int> P(m);
  V<ll> y(m);
  rep(i, m) cin >> P[i] >> y[i];

  V<V<ll>> s(n + 1);
  rep(i, m) s[P[i]].push_back(y[i]);
  rep(i, n + 1) sort(s[i].begin(), s[i].end());

  rep(i, m) {
    int p = P[i];
    auto itr = lower_bound(s[p].begin(), s[p].end(), y[i]);
    int seq = distance(s[p].begin(), itr) + 1;
    printf("%06d%06d\n", p, seq);
  }
}


Measured memory_bytes: 9708
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
    scanf("%d",&n);
     int a[n];
    int i,cnt=0;
   for(i=0;i<n;++i) 
       scanf("%d",&a[i]);
  
    for(i=1;i<=n;++i) 
    {
      if(i!=a[i-1])
          cnt++;
    }
  
    if(cnt<=2)
        printf("YES");
  
    else
        printf("NO");
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    int N = S.size();

    S += '#';
    string T = "";
    for (int i = 0; i < N;) {
        if (S[i] == 'B' && S[i+1] == 'C') {
            T += 'D';
            i += 2;
        } else {
            T += S[i];
            i++;
        }
    }

    int M = T.size();
    ll cnta = 0;
    ll ans = 0;
    rep(i,M) {
        if (T[i] == 'A') cnta++;
        else if (T[i] == 'D') ans += cnta;
        else cnta = 0;
    }

    cout << ans << endl;
}


Measured memory_bytes: 916
#include<iostream>
#include<cmath>
using namespace std;
#define ll long long
ll n,a[100500];
signed main(){
	scanf("%lld",&n);
	ll ans=1;
	for(ll i=0;i<n;i++){
		ll v;
		scanf("%lld",&v);
	a[i]=v;
	if(v==0){printf("%d",0); return 0;
	}
	}
	for(ll i=0;i<n;i++){
		if((ll)pow(10,18)/a[i]<ans){cout<<-1<<endl; return 0;
	}
	ans*=a[i];
	}
	printf("%lld",ans);
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3)
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3)
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int n=a-b;
    if(n>0)
        c-=n;
    if(c<0)
        c=0;
    cout<<c;
}


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

int main() {
  int n, m; cin >> n >> m;
  vector<int> ac(n), wa(n);
  rep(i, m) {
    int p; string t; cin >> p >> t; p--;
    if (ac[p] == 0) {
      if (t == "WA") wa[p]++;
      else ac[p] = 1;
    }
  }
  int AC = 0, WA = 0;
  rep(i, n) {
    AC += ac[i];
    if (ac[i] == 1) WA += wa[i];
  }
  cout << AC << " " << WA << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    string s;
    cin >> s;
    if (s.length() == 3) reverse(ALL(s));
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
from sys import stdin
N = int(stdin.readline().rstrip())
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data
cnt = 0
for i in get_sieve_of_eratosthenes(55555):
    if i % 5 == 1:
        print(i,end=" ")
        cnt += 1
    if cnt == N:
        break

Measured memory_bytes: 4340
using System;
using System.Collections.Generic;
using System.Linq;

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc161_c();
        }

        static void abc161_c()
        {
            // ABC161 C - Replacing Integer
            // m = n % k または k - m の小さいほう
            long[] input = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            long n = input[0];
            long k = input[1];
            long m = n % k;
            long ans = Math.Min(m, k-m);
            Console.WriteLine(ans);
        }
    }
}

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
  NodePointer n;
  for(n=nil;n->next!=nil;n=n->next){
    if(n->next->key==key) return n->next;
  }
  return NULL;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */


  t->prev->next=t->next;
  t->next->prev=t->prev;

  free(t);
}

void deleteFirst(){
  
  NodePointer t = nil->next;

  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */

  deleteNode(nil->prev);
}

void delete(int key){
  /* your code */
  NodePointer n;

  if( ( n=listSearch(key) ) != NULL)  deleteNode(n);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /*  your code  */
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if(strlen(com)<=6){
      scanf("%d", &key);      
      if ( com[0] == 'i' ) insert(key);
      else if ( com[0] == 'd' )  delete(key);
    }
    else{
      if ( com[6] == 'F' ) deleteFirst();
      else if ( com[6] == 'L' ) deleteLast();
    }
  }

  printList();
  return 0;
}



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

int main(){
    long n;
    cin >> n;
    int a[3*n+100];
    for(long i=0;i<3*n;i++)cin >> a[i];
    
    sort(a,a+3*n,greater<long>());
    long sum=0;
    for(long i=0;i<n;i++){
        if(i==0)sum+=a[1];
        else sum+=a[2*i+1];
    }
    
    cout << sum <<"\n";
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		StringBuilder sb = new StringBuilder();
		sb.append(2018);
		sb.append(S.substring(4,10));
		
		System.out.println(sb.toString());
		
	}
}


Measured memory_bytes: 22612