akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long N;
	cin>>N;
	long long ans=0;
	long long dist = 0;
	vector<long long> A(N);
	for(long long i=0;i<N;i++)cin>>A[i];
	for(long long i=1;i<N;i++){
		if(A[i-1]>A[i]){
			dist = A[i-1]-A[i];
			A[i]+=dist;
			ans+=dist;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4840
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

ll f(ll b,ll n){
    if(n<b)return n;

    return f(b,n/b)+n%b;
}
int main(){
    ll n,s;cin>>n>>s;
    ll m=sqrt(n)/1;
    for(int b=2;b<=m;b++){
        if(f((ll)b,n)==s){
            cout<<b<<endl;
            return 0;
        }
    }
    if(m*m==n)m--;
    int i=m;
    while(i>0){
        ll r=s-(ll)i;
        if(r>=0 && (n-r)%i==0){
            ll b=(n-r)/i;
            if(b>r && b>1){
                cout<<b<<endl;
                return 0;
            }
        }
        i--;
    }
    if(n==s){
        cout<<n+1<<endl;
        return 0;
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int len = s.size();
	int flag = 0;
	for (int i = 0; i < len; i++) {
		if (i % 2 && s[i] == 'R') {
			flag = 1;
			break;
		}
		if (i % 2 == 0 && s[i] == 'L') {
			flag = 1;
			break;
		}
	}
	if (flag)
		cout << "No";
	else
		cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE Strict #-}
import           Control.Monad               (forM_)
import qualified Data.ByteString.Char8       as B
import           Data.List                   (unfoldr)
import           Data.Vector.Unboxed         (Vector, (!))
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

main :: IO ()
main = do
  n <- readLn
  as <- readIntsLn
  putStr . unlines . map show $ solve n as

readIntsLn :: IO [Int]
readIntsLn = unfoldr (B.readInt . B.dropWhile (== ' ')) <$> B.getLine

solve :: Int -> [Int] -> [Int]
solve _ as = map (\a -> s - xs ! a + 1) as
  where xs = countOccur as
        s = V.foldr' (\x y -> x * (x - 1) `div` 2 + y) 0 xs

countOccur :: [Int] -> Vector Int
countOccur as = V.create $ do
  v <- VM.new $ 2 * 10 ^ 5 + 1
  forM_ as $ \a -> VM.modify v succ a
  return v


Measured memory_bytes: 20428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

void YesNo(bool x) {
    if (x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    int X; cin >> X;
    YesNo(X >= 30);
}


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

struct UnionFind {
  vector<int> data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
  int n,m;
  cin >> n >> m;
  UnionFind uf(n);

  rep(i,m) {
    int x,y,z;
    cin >> x >> y >> z;
    x--;y--;
    uf.unite(x,y); 
  }
  vector<int> check(n,0);
  int res = 0;
  rep(i,n) if (++check[uf.find(i)] == 1) res++;
    
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
//#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	ll n;
	cin>>n;
	vvi in(n,vi(n));
	rep(i,n)rep(j,n)cin>>in[i][j];
	ll out=0;
	rep(i,n)rep(j,n)out+=min(in[i][j],in[j][i]);
	cout<<out/2<<endl;
}

Measured memory_bytes: 3216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) {
		Main cd = new Main();
        System.out.println(cd.calculate());
	}

    private final String ERROR_INPUT_INT = "入力値は実数ではありません。";

    private String input() throws IOException{
        String line;
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        line = reader.readLine();
        return line;
    }


    public Integer inputInt() { //double型の数値を入力できるメソッド
        try{
            String value = this.input();
            Integer n = Integer.parseInt(value);
            return n;
        }
        catch (Exception s){
            System.out.println(ERROR_INPUT_INT);
            return this.inputInt();
        }
    }

	public double calculate() {
		return 2*this.inputInt()*Math.PI;
	}

}

Measured memory_bytes: 33180
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
  int push(int);
  int pop(void);
  int stack[10000];
  int stack_size=0;
int main(){
  char s[10000];

  scanf("%[^\n]*s",s);
  printf("%d\n",calc(s));
  return 0;
}

int pop(){
  if(stack_size<=0)
    return 0;
  else
    return stack[--stack_size];
}

int push(int n){
  stack[stack_size++]=n;
}

int get_number(char *s){
  int flag=0, n=0;

  if(*s=='+')
    s++;
  else if(*s=='-'){
    flag=1;
    s++;
  }
    while(*s>='0'&&*s<='9'){
      n=n*10+(*s-'0');
      s++;
    }
    
    if(flag)
      return -n;
    return n;
}

int judge(char *s){
  if(*s=='+' || *s=='-'){
    s++;
    if(*s>='0' &&*s<='9')
      return 1;
    return 0;
  }
  if(*s>='0'&&*s<='9')
    return 1;
  return 0;
}
int calc(char *s){
  int a,b,n;
  while(*s){
    if(judge(s)){
	n=get_number(s);
	push(n);
	while(*s=='+'||*s=='+'){
	  s++;
	}
	while(n){
	  n=n/10;
	  s++;
	}
    }
    else{
      switch(*s){
	
      case '+':
	a=pop();
	b=pop();
	push(b+a);
	break;

      case '-':
	a=pop();
	b=pop();
	push(b-a);
	break;

      case '*':
	a=pop();
	b=pop();
	push(b*a);
	break;
      }
      s++;
    }
  }
  return pop();
}

	



Measured memory_bytes: 2088
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var res = -1;
            for (var i = 1; i < 1009; i++)
            {
                if ((int)Math.Floor(i * 0.08) == ab[0] && (int)Math.Floor(i * 0.1) == ab[1])
                {
                    res = i;
                    break;
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13396
#include <cstdio>
 
using namespace std;
 
int dx[] = {1,-1,0,1};
int dy[] = {0,1,1,-1};
 
int main(){
    int n, T = 1;
 
    while(scanf("%d" ,&n), n){
	printf("Case %d:\n" ,T++);
 
	int table[n][n], x = 0, y = 0, num = 0, dir = 0;
	if(n % 2){
	    while(true){
		table[y][x] = ++num;
 
		if(num == n*n){
		    table[n-1][n-1] = num;
		    break;
		}
 
		switch(dir){
		case 0:
		    x += dx[dir];
		    y += dy[dir];
       
		    if(y == 0){
			dir = 1;
		    }else{
			dir = 3;
		    }
		    break;
		case 1:
		    x += dx[dir];
		    y += dy[dir];
       
		    if(y == n-1 && x){
			dir = 0;
		    }else if(x == 0){
			dir = 2;
		    }
		    break;
		case 2:
		    x += dx[dir];
		    y += dy[dir];
       
		    if(x == 0){
			dir = 3;
		    }else{
			dir = 1;
		    }
		    break;
		case 3:
		    x += dx[dir];
		    y += dy[dir];
       
		    if(y == 0 && x != n-1){
			dir = 0;
		    }else if(x == n-1){
			dir = 2;
		    }
		    break;
		}
	    }
	}else{
	    while(num != n*n){
		table[y][x] = ++num;
		if(num == n*n){
		    table[n-1][n-1] = num;
		    break;
		}
 
		switch(dir){
		case 0:
		    x += dx[dir];
		    y += dy[dir];
       
		    if(y == 0){
			dir = 1;
		    }else{
			dir = 3;
		    }
		    break;
		case 1:
		    x += dx[dir];
		    y += dy[dir];
       
		    if(y == n-1){
			dir = 0;
		    }else if(x == 0){
			dir = 2;
		    }
		    break;
		case 2:
		    x += dx[dir];
		    y += dy[dir];
       
		    if(x == 0){
			dir = 3;
		    }else{
			dir = 1;
		    }
		    break;
		case 3:
		    x += dx[dir];
		    y += dy[dir];
       
		    if(x == n-1){
			dir = 2;
		    }else if(y == 0){
			dir = 0;
		    }
		    break;
		}
	    }
	}
 
	for(int i = 0 ; i < n ; i++){
	    for(int j = 0 ; j < n ; j++){
		printf("%3d" ,table[i][j]);
	    }
	    printf("\n");
	}
    }
    return 0;
}

Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;

int n, tab[N], i;
LL res, act, sum;

int main() {
scanf("%d", &n);
sum = 0;
for (i=0;i<=n;i++) {
	scanf("%d", &tab[i]);
	sum += tab[i];
}
if (n == 0) {
	if (tab[0] == 1) printf("1\n"); else printf("-1\n");
	return 0;
}
if (tab[0] > 0) {
	printf("-1\n");
	return 0;
}
res = 1;
act = 1;
for (i=1;i<=n;i++) {
	act = min(act * 2, sum);
	//printf("%lld\n", act);
	res += act;
	if (act < tab[i]) {
		printf("-1\n");
		return 0;
	}
	act -= tab[i];
	sum -= tab[i];
}
printf("%lld\n", res);
return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define test(t) int t;cin>>t;while(t--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
const int MOD = 1e9+7,MAX = 1e5+5;
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
ll modInv(ll a)
{
	return powN(a,MOD-2);
}


int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		s[i]=(s[i]-'A'+n)%26+'A';
	}
	cout<<s<<endl;
}

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


int main(){
    ll n,m,x;cin>>n>>m>>x;
    ll c[20],a[22][22];
    rep(i,0,n){
        cin>>c[i];
        rep(j,0,m)cin>>a[i][j];
    }
    ll rikai[20],an=1e12,tot=0;
    rep(i,0,(1<<n)){
        tot=0;
        rep(j,0,m)rikai[j]=0;
        rep(j,0,n){
            if(i&(1<<j)){
                tot+=c[j];
                rep(k,0,m)rikai[k]+=a[j][k];
            }
        }
        int ok=1;
        rep(k,0,m)if(rikai[k]<x)ok=0;
        if(ok)an=min(an,tot);
    }
    if(an==1e12)cout<<-1<<endl;
    else cout<<an<<endl;
    
}

    









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

using namespace std;

int main() {
    string s;
    cin >> s;
    int result = 0;
    for(int i = 0; i < s.length(); i++) {
        for(int j = i; j < s.length(); j++) {
            int k;
            for(k = i; k <= j; k++) {
                if(s[k] != 'A' && s[k] != 'C' && s[k] != 'G' && s[k] != 'T') {
                    break;
                }
            }
            if(k == (j+1)) {
                result = max(result, j-i+1);
            }
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 3588
//#define _GLIBCXX_DEBUG
//#define _CRTDBG_MAP_ALLOC
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll LINF = 9187201950435737471;
const ll nLINF = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const int MAXN = 2000 + 15;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const int BLOCK = 500;
const double PI = acos(-1);
//auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
auto seed = 194113341;
mt19937 rnd(seed);

bool isEqual(double a, double b) {
    return abs(a - b) <= EPS;
}

#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) ((_v) * (_v))
#define vi vector <int>
#define vpi vector <pair <int, int> >
#define eb emplace_back
#define pb push_back
#define mod(x, m) ((x) % m + (x < 0 ? m: 0))


inline void IO() {
#if buyolitsez
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
}

template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

//#define int int64_t

void solve() {
    int k;
    string s;
    cin >> k >> s;
    bool flag = 0;
    if (sz(s) > k) {
        flag = 1;
    }
    while (sz(s) > k) {
        s.pop_back();
    }
    if (flag) {
        s += "...";
    }
    cout << s;
}

signed main() {
    IO();
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define _GLIBCXX_DEBAC
using namespace std;
	
int findx(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}

	return sum;
}

string divide[4] = { "dream","dreamer","erase","eraser" };

int main() {
	int n, k;
	cin >> n >> k;
	int sum = 0,x=0;
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (x >= k) sum += 1;
	}
	cout << sum;
	return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int n;cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    int po=n/i;
    ans+=i*(po+1)*po/2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3616
import java.util.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long k = Long.parseLong(sc.next());
        TreeMap<Integer,Long> map = new TreeMap<Integer,Long>();
        for(int i=0;i<n;i++){
            int a = Integer.parseInt(sc.next());
            long b = Long.parseLong(sc.next());
            if(map.containsKey(a)){
                map.put(a,map.get(a)+b);
            }else{
                map.put(a,b);
            }
        }
        long idx = 0; 
        for(int key:map.keySet()){
            idx += map.get(key);
            if(idx>=k){
                System.out.println(key);
                return;
            }
        }
        return;
    }
}

Measured memory_bytes: 66224
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int first = 0;
		int second = 0;
		int firstIndex = -1;
		for(int i=0;i<N;i++){
			int A = sc.nextInt();
			if(A == first){
				firstIndex = -1;
			}else if(A > first){
				second = first;
				first=A;
				firstIndex = i;
			}else if(A>second)second=A;
		}
		if(firstIndex==-1){
			for(int i=0;i<N;i++){
				System.out.println(first);
			}	
		}else{
			for(int i=0;i<N;i++){
				if(firstIndex == i){
					System.out.println(second);
				}else{
					System.out.println(first);
				}
			}
		}
	}
}

Measured memory_bytes: 89872
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N, R; {int[] a = in.ii(); N = a[0]; R = a[1];}
        int ans;
        if(N >= 10){
            ans = R;
        } else {
            ans = R + 100*(10-N);
        }
        out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


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

#define BUF_SIZE 30003

#define SECRET_DIGIT 3

int get_int(void) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
#else
#error
#endif
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  int num;
  sscanf(line, "%d", &num);
  return num;
}

int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int main(void) {
    char lucky_str[BUF_SIZE];
    int digits = get_int();
    get_str(lucky_str, BUF_SIZE);
    int i, j, k;
    int idx;
    char secret_key[3];

    int ans = 0;

    for(i = 0; i < 10; i++) {
        for(j = 0; j < 10; j++) {
            for(k = 0; k < 10; k++) {
                // assume that i*100+j*10+k
                secret_key[0] = i+'0';
                secret_key[1] = j+'0';
                secret_key[2] = k+'0';
                int s_idx = 0;
                for(idx = 0; idx < digits && s_idx < 3; idx++) {
                    if(secret_key[s_idx] == lucky_str[idx]) s_idx++;
                }
                if(s_idx == SECRET_DIGIT) ans++;
            }
        }
    }
    printf("%d\n", ans);

    return 0;
}

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

int k, n, p[300000], q[300000];

int main(){
  cin >> n >> k;
  rep(i, n){
    cin >> p[i];
    p[i]++;
  }
  q[0] = 0;
  rep(i, n){
    q[i + 1] = q[i] + p[i];
  }
  /*
  rep(i, n){
    cerr << p[i] << " ";
  }cerr << endl;
  rep(i, n + 1){
    cerr << q[i] << " ";
  }cerr << endl;
  */
  
  int tmp = 0;
  rep(i, n - k + 1){
    //cerr << q[i + k] <<" "<< q[i] << endl;
    tmp = max(q[i + k] - q[i], tmp);
  }
  double res = (double)tmp / 2;
  cout << setprecision(10) << res << endl;
  return 0;
}


Measured memory_bytes: 1792
program main_a
   implicit none
   integer :: A(32), K

   data A/1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51/

   read(*,*) K

   print *, A(K)

end program main_a


Measured memory_bytes: 768
import Control.Monad

main = do
  n <- readLn
  [d, x] <- map read . words <$> getLine
  as <- replicateM n readLn :: IO [Int]
  print $ solve d as + x

solve d as =
  sum $ map length $ map (takeWhile (<=d)) $ map go as
  where
    go a =
      map (\x -> x*a+1) [0..]


Measured memory_bytes: 1020
n, k, s = map(int, input().split())
INF = 10**9

if n == k:
    a = [s] * n
    for i in a:
        print(i, end=' ')

else:
    if s != INF:
        a = [INF] * n
        for i in range(k):
            a[i] = s
        for i in a:
            print(i, end=' ')
    else:
        a = [1] * n
        for i in range(k):
            a[i] = INF
        for i in a:
            print(i, end=' ')

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

using namespace std;

long long MOD=1000000007;

long long add_mod(long long x,long long y){
	return (x+y)%MOD;
}

long long sub_mod(long long x,long long y){
	return (x-y+MOD)%MOD;
}

long long mul_mod(long long x,long long y){
	return x*y%MOD;
}

int n,m;

void solve(){
    int i,j;
    string str;
    cin >> n >> m;
    vector<int> a(n),b(m);
    for(i = 0;i < n;i++) cin >> a[i];
    for(i = 0;i < m;i++) cin >> b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    for(i = 1;i < n;i++) if(a[i-1] == a[i]){
        cout << 0 << endl;
        return;
    }
    for(i = 1;i < m;i++) if(b[i-1] == b[i]){
        cout << 0 << endl;
        return;
    }
    long long x = 0,y = 0;
    int ai = n-1,bi = m-1;
    long long ans = 1;
    for(i = n*m;i > 0;i--){
        if(a[ai] == i && b[bi] == i){
            x++;
            y++;
            ai--;
            bi--;
        }
        else if(a[ai] == i){
            ans = mul_mod(ans,y);
            x++;
            ai--;
        }
        else if(b[bi] == i){
            ans = mul_mod(ans,x);
            y++;
            bi--;
        }
        else{
            long long e = x*y-(n*m-i);
            if(e <= 0){
                cout << 0 << endl;
                return;
            }
            ans = mul_mod(ans,e);
        }
    }
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define endl '\n'
#define ll long long
using namespace std;

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

	string s;
	cin >> s;
	ll sum = 0;
	int len = s.length();
	for (int i = 0; i < len; i++) {
		sum += s[i] - '0';
	}
	cout << (sum % 9 == 0 ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF ll(1e18)
#define MOD (ll)1e9+7
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	string s;cin>>s;
	for(int i=0;i<3;i++){
        if(s[i]=='7'){
            cout<<"Yes\n";return 0;
        }
	}cout<<"No\n";
}


Measured memory_bytes: 3652
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    P = [i - 1 for i in map(int, input().split())]

    ans = 0
    flag = False
    for i, p in enumerate(P):
        if i == p and flag:
            flag = False
        elif i == p:
            ans += 1
            flag = True
        elif flag:
            flag = False
        else:
            continue

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 13876
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    double H = sc.nextInt();
    double M = sc.nextInt();
    // A * A + B * B - 2AB cosA
    // 何度進んでいるか
    double HAngle = H * 30  + M * 0.5;
    double MAngle = M * 6;
    double angle = HAngle - MAngle;
    if (angle < -90 || 90 < angle) {
        angle = 360 - Math.abs(angle);
    }
    double cosA = Math.cos(Math.toRadians(angle));
    double answer = Math.sqrt(A * A + B * B - (2 * A * B * cosA));
    System.out.println(answer);
  }
}

Measured memory_bytes: 35976
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
				Scanner sc=new Scanner (System.in);
		
		int ass=0;
		int nod=sc.nextInt();
		int t=sc.nextInt();
		while (t>0)
		{
		    ass=ass+sc.nextInt();
		    t--;
		}
		if(nod>=ass)
		System.out.println(nod-ass);
		else System.out.println(-1);
		
	}
}


Measured memory_bytes: 46268
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int N,K;
	cin>>N>>K;
	
	vector<int> p(N);
	for(int i=0;i<N;i++)cin>>p[i];
	sort(p.begin(),p.end());
	int ans = 0;
	for(int i=0;i<K;i++)ans += p[i];
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		int w = Integer.parseInt(input());
		int[] amida = new int[w];

		for (int i = 0; i < w; i++) {

			amida[i] = i + 1;

		}

		int n = Integer.parseInt(input());

		for (int j = 0; j < n; j++) {

			String[] change = input().split(",");
			int temp = amida[Integer.parseInt(change[0]) - 1];
			amida[Integer.parseInt(change[0]) - 1] = amida[Integer.parseInt(change[1]) - 1];
			amida[Integer.parseInt(change[1]) - 1] = temp;

		}

		for (int k: amida) {

			System.out.println(k);

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26144
import java.util.*;

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

class Solver {

    private boolean check(int[] curX , int X) {
        for (int i = 0; i < curX.length; i++) {
            if (curX[i] < X) return false;
        }
        return true;
    }

    private int calc(int N, int M, int X, int[] cost, int[][] A, int pos, int curC, int[] curX) {
        if (pos == N) {
            if (check(curX, X)) return curC;
            else return Integer.MAX_VALUE;
        }

        // skip the book
        int c1 = calc(N, M, X, cost, A, pos + 1, curC, curX);

        // buy the book


        int[] newX = Arrays.copyOf(curX, curX.length);
        for (int i = 0; i < M; i++) {
            newX[i] += A[pos][i];
        }
        int c2 = calc(N, M, X, cost, A, pos + 1, curC + cost[pos], newX);

        return Math.min(c1, c2);
    }


    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();

        int[] C = new int[N];
        int[][] A = new int[N][M];
        for (int i = 0; i < N; i++) {
            C[i] = sc.nextInt();
            for (int j = 0; j < M; j++) {
                A[i][j] = sc.nextInt();
            }
        }

        int[] v = new int[M];
        int min = calc(N, M, X, C, A, 0, 0, v);
        System.out.println(min == Integer.MAX_VALUE ? -1 : min);
        return;
    }

}

Measured memory_bytes: 37988
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.next().toLong()
    val b = sc.next().toLong()
    val c = sc.next().toLong()
    val d = sc.next().toLong()

    println(abc131c(a, b, c, d))
}

private fun abc131c(a: Long, b: Long, c: Long, d: Long): Long {
    var l = lcm(c, d)

    var ans = b - a + 1
    ans -= (b / c) + (b / d) - (b / l)
    ans += ((a - 1) / c) + ((a - 1) / d) - ((a - 1) / l)

    return ans
}

private fun lcm(a: Long, b: Long): Long {
    return a / gcd(a, b) * b
}

private fun gcd(a: Long, b: Long): Long {
    if (b > 0) {
        return gcd(b, a % b)
    }
    return a
}

Measured memory_bytes: 31524
#include <iostream>
#include <algorithm> // sort
#include <map>       // pair
using namespace std;

char in[120];
pair<pair<string,int>,int> p[110];
int main(){
    int a;scanf("%d",&a);
    for(int i=0;i<a;i++){
        int t;scanf("%s%d",in,&t);
        //string tmp=in;
        p[i]=make_pair(make_pair(in,-t),i);
    }
    //pをベクトルで宣言した場合sort(p.begin(),p.end())
    sort(p,p+a);

    for(int i=0;i<a;i++)printf("%d\n",p[i].second+1);
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    while(ans < 1e6)
    {
        if(a % 2 || b % 2 || c % 2)
        {
            cout << ans << endl;
            return 0;
        }
        ans++;
        int na = (b+c) / 2;
        int nb = (a+c) / 2;
        int nc = (a+b) / 2;
        a = na;
        b = nb;
        c = nc;
    }
    cout << -1 << endl;
}




Measured memory_bytes: 3620
import re
s = input()
ss = re.findall(r">+|<+",s,re.S)
count = 0
num = 0
if re.findall(">",ss[0],re.S):
    count += sum(range(len(ss[0])+1))
    del ss[0]
if ss and re.findall("<",ss[-1],re.S):
    count += sum(range(len(ss[-1])+1))
    del ss[-1]
for i in range(len(ss)-1):
    if num == 0:
        num = max(len(ss[i]),len(ss[i+1]))
        count += sum(range(max(len(ss[i]),len(ss[i+1]))+1))
        count += sum(range(min(len(ss[i]),len(ss[i+1]))))
    else:
        num = 0
print(count)

Measured memory_bytes: 13340
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
		sc.close();
		int count = 0;
		for(int i= 0;i<3;i++) {
			if(s.charAt(i) == t.charAt(i)) count++;
		}
		
		System.out.println(count);
		
	}

}


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

int main() {
	int row, col;
	cin >> row >> col;
	char arr[row+2][col+1];
	for (int i=0; i<row+2; i++){
		for (int j=0; j<col+2; j++){
			if (i==0 or j==0 or i==row+1 or j==col+1){
				arr[i][j]=0;
			}
			else cin>> arr[i][j];
		}
	}
	for (int i=0; i<row+2; i++){
		for (int j=0; j<col+2; j++){
			if (arr[i][j]=='.'){
				int sum = 0;
				if (arr[i-1][j-1]=='#') sum++;
				if (arr[i-1][j]=='#') sum++;
				if (arr[i-1][j+1]=='#') sum++;
				if (arr[i][j-1]=='#') sum++;
				if (arr[i][j+1]=='#') sum++;
				if (arr[i+1][j-1]=='#') sum++;
				if (arr[i+1][j]=='#') sum++;
				if (arr[i+1][j+1]=='#') sum++;
				arr[i][j]=char(sum+'0');
			}
		}
	}
	for (int i=1; i<row+1; i++){
		for (int j=1; j<col+1; j++){
			cout << arr[i][j];
		}
		cout << endl;
	}
}
	

Measured memory_bytes: 3012
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
    int n;
    cin>>n;
    map<int,int> mp;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        mp[arr[i]]++;
    }
    int cnt=0;
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        int val=it->second;
        cnt+=((val)*(val-1))/2;
        //cout<<cnt<<endl;
    }
    
    int res[n]={0};
    for(int i=0;i<n;i++)
    {
        res[i]=cnt-mp[arr[i]]+1;
    }
    for(int i=0;i<n;i++)
    cout<<res[i]<<endl;
}

Measured memory_bytes: 12672
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<deque>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
int N, K, d[52], ans = 0;//ori:0

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> d[i];
	
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j + i <= K; j++) {
			int tmp = 0, cnt = 0;
			vector<int>mj;//minus jewely
			//左iつ、右min(j,N-i)つとる
			for (int x = 0; x < min(i, N); x++) {
				tmp += d[x];
				if (d[x] < 0) {
					cnt++;
					mj.push_back(d[x]);
				}
			}
			for (int x = N - 1; x > max(i, N - 1 - j); x--) {
				tmp += d[x];
				if (d[x] < 0) {
					cnt++;
					mj.push_back(d[x]);
				}
			}
			sort(mj.begin(), mj.end());
			for (int k = 0; k < min(cnt, K - i - j); k++)tmp -= mj[k];
			ans = max(ans, tmp);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<ll>sumr(n+1),sumw(n+1);
  rep(i,n){
    if(s[i]=='R'){
      sumr[i+1]=sumr[i]+1;
      sumw[i+1]=sumw[i];
    }
    if(s[i]=='W'){
      sumw[i+1]=sumw[i]+1;
      sumr[i+1]=sumr[i];
    }
  }
  ll ans=n;
  rep(i,n+1){
    ll num = min(sumw[i],sumr[n]-sumr[i]);
    ans=min(ans,num+max(sumw[i]-num,sumr[n]-sumr[i]-num));
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 6800
import java.util.Scanner;
 
class Main {
 
	public static void main(String[] args) {
		
		Scanner stdIn = new Scanner(System.in);
 
		String A = stdIn.next();
		
	if( A.charAt(0)==A.charAt(1) && A.charAt(1)==A.charAt(2) ){
			System.out.println("No");
        }else{
			System.out.println("Yes");
    	}
 
	}
    
}

Measured memory_bytes: 20820
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b,int m) {
    if (b==0) return 1;
    ll c = power(a,b>>1,m);
    c = (c*c)%m;
    if (b&1) return (c*a)%m;
    return c;
}
ll powerwithoutmod(ll a,ll b) {
    if (b==0) return 1;
    ll c = powerwithoutmod(a,b>>1);
    c = (c*c);
    if (b&1) return (c*a);
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int Q = 301;
const int logN = 16;

void solve() {
    int a,b;
    cin>>a>>b;
    REP(i,1,10000) {
        if ((i*8)/100==a && (i*10)/100==b) {
            cout<<i;
            return;
        }
    }
    cout<<-1;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 256
s = input()

a = int(s[0] + s[1])
b = int(s[2] + s[3])

if 1 <= a <= 12 and 1 <= b <= 12:
    ans = "AMBIGUOUS"
elif 1 <= a <= 12:
    ans = "MMYY"
elif 1 <= b <= 12:
    ans = "YYMM"
else:
    ans = "NA"
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
int A,B;
int main(){
    cin >> A >> B;
    cout << ((A+B>=24)? A+B-24 : A+B) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	int a[n];
	int ans=1000000000;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans=min(ans,__builtin_ctz(a[i]));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();

        Set<Long> set = new HashSet<>();
        for (int i = 1 ; i <= Math.sqrt(n) ; i++) {
            if (n % i == 0) {
                set.add((long) i);
                set.add(n / i);
            }
        }

        long ans = 0;
        for (Long num : set) {
            long cand = num - 1;
            if (cand > 0 && n / cand == n % cand) {
                ans += cand;
            }
        }

        System.out.println(ans);

    }

}


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

using namespace std;

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

    vector<int> l(n, 0), r(n, 0);
    for (int i=0; i<n; i++) {
        if (s[i] == 'W') {
            if (i == 0)
                l[i]++;
            else
                l[i] = l[i-1]+1;
        }
        else
            l[i] = l[i-1];
    }

    for (int i=n-1; i>=0; i--) {
        if (s[i] == 'E') {
            if (i == n-1)
                r[i]++;
            else
                r[i] = r[i+1]+1;
        }
        else
            r[i] = r[i+1];
    }

    int ans = INT_MAX;
    for (int i=0; i<n; i++) {
        if (i == 0)
            ans = min(ans, r[i+1]);
        else if (i == n-1)
            ans = min(ans, l[i-1]);
        else
            ans = min(ans, l[i-1]+r[i+1]);
    }

    cout << ans << endl;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string s,t; cin >> s >> t;
  static string mp[3001][3001] = {};
  int slen = (int)s.size(), tlen = (int)t.size();
  vector<vector<int>> dp(slen+1,vector<int>(tlen+1,0));
  for(int i = 1; i <= slen; ++i){
    for(int j = 1; j <= tlen; ++j){
      dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
      mp[i][j] = (dp[i-1][j] < dp[i][j-1] ? mp[i][j-1] : mp[i-1][j]);
      if(s[i-1] == t[j-1]){
	if(ChangeMax(dp[i][j],dp[i-1][j-1] + 1)) mp[i][j] = mp[i-1][j-1] + s[i-1];
      }
      mp[i-1][j-1]="";
      mp[i-1][j-1].shrink_to_fit();
    }    
  }
  cout << mp[slen][tlen] << endl;
  return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  cout << a.back() - a[0] << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		if(n % 2 == 0) {
			System.out.println(n);
			return;
		}
		else {
			System.out.println(2 * n);
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
#define PI acos(-1)
#define deb(x) cout<<#x<<" "<<x<<endl;
//ALWAYS USE ll DATA TYPE FOR INTEGER(FASTER THAN INTEGER AS WELL AS SOMETIMES WITHOUT USE LONG UR ANSWER WILL NOT ACCEPTED) && DOUBLE FOR DECIMAL VALUE
template<typename T> // for removing front element from the vector
void pop_front(std::vector<T> &v)
{
    if (v.size() > 0) {
        v.erase(v.begin());
    }
}
template<typename R> // for removing back element from the vector or can directly
void pop_back(std::vector<R> &v) // use vec.pop_back() function...
{
    if (v.size() > 0) {
        v.erase(v.begin()+v.size()-1);
    }
}

bool isprime(ll n)  //IN  O(sqrt(n))
{
    if(n<=1) return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;

    return true;
}

vector<ll> factors(ll n){    //IN  O(sqrt(n))

    vll v;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            v.pb(i);
            if((n/i)!=i)
            v.pb(n/i);
        }
    }
    return v;
}

ll power(ll a, ll n)  // using Binary Exponential in TC O(logn)
{                     // Self Written By </ME> :)
    ll res=1;
    while(1)
    {
        if(n%2){
            res=res*a; n--;
        }
        if(n==0) break;
        a=a*a; n/=2;
    }
    return res;
}

ll ts(ll arr[],int l,int r,int x) // ternary search to find x in sorted array arr
{
    
    while(l<=r)
    {
        ll mid1= l+(r-l)/3;
        ll mid2= r -(r-l)/3;
        if(arr[mid1]==x || arr[mid2]==x)
            return 1;
        if(x<arr[mid1])
            r=mid1-1;
        else if(x>arr[mid2])
            l=mid2+1;
        else
        {
            l=mid1+1;
            r=mid2-1;
        }
    }

    return -1;
}

int main() {
    //auto start = chrono::high_resolution_clock::now();
    fio;
    ll t=1;
    //cin>>t;
    while(t--)
    {
      ll a,b; cin>>a>>b;
      for(ll i=1;i<=10000;i++)
      {
        ll v1 = i*8/100;
        ll v2 = i*10/100;
        if(v1==a && v2==b)
        {
            cout<<i<<"\n";
            return 0;
        }    
    }

    cout<<-1<<"\n";

    }

    
    //auto finish = chrono::high_resolution_clock::now();
    //cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
    return 0;
}





Measured memory_bytes: 256
import java.util.Scanner;

/**
 * http://abc086.contest.atcoder.jp/tasks/abc086_c
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Point[] points = new Point[N+1];
		points[0] = new Point(0, 0, 0);
		for(int i=1; i<=N; i++){
			points[i] = new Point(sc.nextInt(), sc.nextInt(), sc.nextInt());
		}
		sc.close();
		
		String ans = "Yes";
		for(int i=1; i<=N; i++){
			Point p1 = points[i-1];
			Point p2 = points[i];
			int d = Math.abs(p1.x-p2.x)+Math.abs(p1.y-p2.y);
			int t = p2.t-p1.t;
			if(d<=t && d%2==t%2) continue;
			ans = "No";
			break;
		}
		
		System.out.println(ans);
		

	}
	
	static class Point{
		int x;
		int y;
		int t;
		Point(int t, int x, int y){
			this.t = t;
			this.x = x;
			this.y = y;
		}
	}

}

Measured memory_bytes: 92560
#include<iostream>
#include<vector>
#include<algorithm>
#define M 1000000007
using namespace std;

long long mod(long long a, long long b)
{
    long long r = a % b;
    return r < 0 ? r + b : r;
}

int main()
{
		int n,k,val=0;
		cin>>n>>k;
		std::vector<long long> v;
		v.resize(n);

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

		sort(v.begin() , v.begin()+n);

		long long product=1;
		int start = 0 , end = n-1;

		if(v[end]<0)
		{	
			if(k&1)
			{
				for(int i=0;i<k;i++)
				{
					product = mod(mod(product,M) * mod(v[end-i],M) , M);
				}
				cout<<product<<endl;
				val=1;
			}
			else
			{
				for(int i=0;i<k;i++)
				{
					product = mod(mod(product,M) * mod(v[i],M) , M);
				}
				cout<<product<<endl;
				val=1;
			}
		}

		while(k>0)
		{
			if(k&1)
			{	
				product = mod(mod(product,M) * mod(v[end],M) , M);
				end--;
				k--;
			}
			else
			{	
				long long temp1 = v[start]*v[start+1];
				long long temp2 = v[end]*v[end-1];

				product = mod(mod(product,M) * mod(max(temp1,temp2),M),M);
				if(temp1>temp2)	start += 2;
				else end -= 2;
				k -= 2;
			}
		}
		if(val==0)
		    cout<<product<<endl;
}

Measured memory_bytes: 4840