akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String b = sc.nextLine();

        if (a.charAt(0) == b.charAt(2) && a.charAt(1) == b.charAt(1) && a.charAt(2) == b.charAt(0))
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


Measured memory_bytes: 35708
#include<iostream>}

#include<cstdio>

using namespace std;

int main()
{
	int a;
	int b;
	int i = 1;
	while (1)
	{
		cin >> a >> b;
		if (a == 0 && b == 0){
			break;
		}
		if (a > b){
			cout << b << " " << a << endl;
		}
		else{
			cout << a << " " << b << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r * r * pi;
        double length = 2 * r * pi;
        
        System.out.printf("%f %f", area, length);
        sc.close();
    }
}


Measured memory_bytes: 28224
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define DSORT(c, type) sort(ALL(c), greater<type>())

using namespace std;


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

  string s; cin >> s;
  int size = SZ(s);

  for(int i=0; i<size-1; ++i){
    if(s[i] == s[i+1]){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
    if(i+2 < size && s[i] == s[i+2]){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }

  cout << "-1 -1\n";
  return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

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

	uint32_t n, k, count = 0;
	cin >> n >> k;

	uint16_t h;
	for (uint32_t i = 0; i < n; ++i) {
		cin >> h;
		if (h >= k) {
			++count;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll NN;
  std::cin >> NN;

  std::vector<ll> v(NN);
  for (size_t i = 0; i < NN; i++) {
    std::cin >> v[i];
  }
  // sort(v.begin(), v.end());

  // for (size_t i = 0; i < NN; i++) {
  //   std::cout << v[i] << '\n';
  // }

  ll num_of_zero = 0;

  while (true) {
    sort(v.begin(), v.end());

    // ll c_start = num_of_zero;
    while(v[num_of_zero] == 0){
      num_of_zero ++;
      // c_start ++;
    }
    if (num_of_zero == NN-1) {
      break;
    }

    // std::cout << "\n"<<"------------" << '\n';
    // for (size_t k = 0; k < NN; k++) {
    //   std::cout << v[k]<<" ";
    // }


    for (size_t j = num_of_zero + 1; j < NN; j++) {
      v[j] = v[j]%v[num_of_zero];
    }


  }

  // std::cout << "\n"<<"------------" << '\n';

  std::cout << v[NN-1] << '\n';



  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final int n=300000;
		Scanner sc=new Scanner(System.in);
		boolean ms[]=new boolean[n];

		for(int i=0;i<n;i++){
			if(i%7==1 || i%7==6){
				ms[i]=true;
			}
			else ms[i]=false;
		}
		ms[1]=false;
		for(int i=2;i<=Math.sqrt(n);i++){
			if(ms[i]){
				for(int j=i*2;j<n;j+=i){
					ms[j]=false;
				}
			}
		}
		while(true){
			int m=sc.nextInt();
			if(m==1) break;
			boolean flag=true;
			for(int i=0;i<n;i++){
				if(ms[i] && m%i==0){
					if(flag){
						System.out.print(m+":");
					}
					System.out.print(" "+i);
					flag=false;
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 13000
N, M, K =map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))  
sum_A = [0]
sum_B = [0]
for a in range(len(A)):
    sum_A.append(sum_A[a]+A[a])

for b in range(len(B)):
    sum_B.append(sum_B[b]+B[b])

len_A = len(sum_A)
j = len(sum_B) - 1
ans = 0
for i in range(len_A):
    a = sum_A[i]
    while True:
        if j < 0:
            break
        if a + sum_B[j] <= K:
            ans = max(ans,i + j)
            break
        j -= 1
    if j < 0:
        break

print(ans)

Measured memory_bytes: 47416
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    string s, t;
    cin >> n >> s >> t;

    int ans = 0;
    for (int i = 0; i <= n; i++) {
        // i文字一致する

        bool same = true;
        for (int j = 0; j < i; j++) {
            if (s[n-i+j] != t[j]) {
                same = false;
            }
        }

        if (same) {
            ans = i;
        }
    }

    cout << 2 * n - ans << "\n";
    return 0;
}

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

using namespace std;

typedef long long int ll;
#define inf 0x3f3f3f3f
#define endl '\n'
// #define case(i) "Case #" << i << ": "

int n, k;
vector<int> v;
int dp[100001];

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

    cin >> n >> k;
    v.resize(n);

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

    dp[0] = 0;

    for(int i = 1; i < n; ++i) {
        int mn = inf;
        for(int j = 1; j <= k && i - j >= 0; ++j) {
            mn = min(mn, dp[i-j] + abs(v[i] - v[i-j]));
        }
        dp[i] = mn;
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void solve()
{
  ll n;
  cin>>n;
  
  ll b[n+1],a[n+1],i;
  
  b[0]=b[n]=INT_MAX;
  
  for(i=1;i<n;i++)
  cin>>b[i];
  
  for(i=2;i<=n-1;i++)
  a[i]=min(b[i-1],b[i]);
  
  a[1]=b[1];
  a[n]=min(b[n],b[n-1]);
  
  ll sum=0;
  
  for(i=1;i<=n;i++)
  sum+=a[i];
  
  cout<<sum;
  
  return;
  
  
}

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

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

int main(){
  string s;
  cin >> s;
  int ans = 999, tmp, sa;
  for (int i = 0; i < s.size() - 2; i++){
    tmp = ((int)s.at(i) - 48) * 100 + ((int)s.at(i + 1) - 48) * 10 + ((int)s.at(i + 2) - 48);
    sa = abs(tmp - 753);
    ans = min(sa, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    int max = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if (max <= fabs(a[i]-a[j])){
                max = fabs(a[i]-a[j]);
            }
        }
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */

#define MAXN (200000)

typedef struct list
{
    int v;
    struct list* n;
}list;

list oya[MAXN+1];
int x[MAXN+1];
int ans[MAXN+1];
int n,q;

void dfs(int v,int p)
{
    list* i = oya[v].n;

    while(i != NULL)
    {
        if(i->v!=p)
        {
            ans[i->v] = ans[v] + x[i->v];
            dfs(i->v, v);
        }
        i = i->n;
    }
}

void add(int a,int b)
{
    list * l;
    l = malloc(sizeof(list));
    l->v = b;
    l->n = oya[a].n;
    oya[a].n = l;
}

int main(void)
{
    int q;
    scanf("%d %d",&n,&q);
    for(int i=0;i<n-1;i++) 
    {
        int a,b;
        scanf("%d %d", &a,&b);
        add(a,b);
        add(b,a);
    }
    for(int i=0;i<q;i++) 
    {
        int p,xx;
        scanf("%d %d", &p,&xx);
        x[p] += xx;
    }
    ans[1] = x[1];
    dfs(1,0);
    for(int i=1;i<=n;i++)
    {
        printf("%d ",ans[i]);
    }
    printf("\n");
    return 0;
}




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

typedef long long ll;
const ll INF = 1e18L + 5;

void min_self(ll &a, ll b) {
    a = min(a, b);
}

int main() {
    int N, W;
    scanf("%d%d", &N, &W);

    vector<int> weight(N), value(N);

    int max_val = 0;

    for (int i = 0; i < N; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
        max_val += value[i];
    }

    vector<ll> dp(max_val+1, INF);
    dp[0] = 0;
    // dp[i] - the minimum weight achievable by taking items of value exactly i

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

        for (int v = max_val; v >= value[i]; --v)
            min_self(dp[v], dp[v-value[i]] + weight[i]);
    }

    ll ans = 0;

    for (ll i = 0; i <= max_val; ++i) {
        if (dp[i] <= W) ans = max(ans, i);
    }

    printf("%lld\n", ans);
}

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

int data[26][26];
bool visited[26];
bool exist[26];

void rec(int now) {
  visited[now] = true;
  for(int i = 0; i < 26; i++) {
    if(exist[i] && !visited[i] && data[now][i] != 0) {
      rec(i);
    }
  }
}

main() {
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;
    fill(data[0], data[0]+26*26, 0);
    fill(exist, exist+26, false);
    for(int i = 0; i < n; i++) {
      string str;
      cin >> str;
      data[str[0]-'a'][str[str.length()-1]-'a'] += 1;
      exist[str[0]-'a'] = exist[str[str.length()-1]-'a'] = true;
    }

    int num[26];
    fill(num, num+26, 0);

    for(int i = 0; i < 26; i++) {
      for(int j = 0; j < 26; j++) {
	if(data[i][j] >= 0) {
	  num[i] += data[i][j];
	  num[j] -= data[i][j];
	}
      }
    }

    bool flag = true;
    for(int i = 0; i < 26; i++) {
      if(num[i] != 0) {
	flag = false;
	break;
      }
    }

    if(flag == true) {
      fill(visited, visited+26, false);
      int cnt = 0;
      for(int i = 0; i < 26; i++) {
	if(exist[i] && !visited[i]) {
	  rec(i);
	  cnt++;
	}
      }
      if(cnt != 1) flag = false;
    }

    if(flag) cout << "OK" << endl;
    else     cout << "NG" << endl;
  }
}

Measured memory_bytes: 912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main (String[] args) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int y = (int)(sc.nextLong() / 1000);
        int a, b = 0;
        for (a = 0; a <= n; a++){
            for(b = 0; b <= n; b++){
                if(a + b > n)
                    continue;
                if(10 * a + 5 * b + (n - a - b) == y)
                    break;
            }
            if(b <= n)
                break;
        }
        if(a > n)
            System.out.println("-1 -1 -1");
        else
            System.out.println(a + " " + b + " " + (n - a - b));
    }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int N;
    string S, T;
    cin >> N >> S >> T;
    for (int i = 0; i < N; ++i)
        cout << S[i] << T[i];
    cout << endl;
    return 0;
}


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

const int INF = 1000000000;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;

		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}

    int d[m][m];
    for(int i=0;i<m;i++){
      for(int j=0;j<m;j++){
        d[i][j]=T[i][j];
      }
    }
    for(int k=0;k<m;k++){
      int count=0;
      for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
          if(d[i][j]>d[i][k]+d[k][j]){
            d[i][j]=d[i][k]+d[k][j];
						d[j][i]=d[j][k]+d[k][i];
          }
        }
      }
		}
		int l=0;
		int count=10000000;
		for(int i=0;i<m;i++){
			int a=0;
			for(int j=0;j<m;j++){
				int l=0;
				a+=d[i][j];
			}
			if(a<count){
				count=a;
				l=i;
			}
		}
		cout<<l<<" "<<count<<endl;
	}

	return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x,y;
    ll cnt=0;
    cin >> x >> y;
    if(x>=0 && y>=0){
        if(x>y){
            x=0-x;
            ++cnt;
            while(1){
                if(abs(x)==abs(y)) break;
                ++x; ++cnt;
            }
            if(y!=0) ++cnt;
        }else{
            while(1){
                if(x==y) break;
                ++x; ++cnt;
            }
        }
    }else if(x<0 && y<0){
        if(abs(x)>=abs(y)){
            while(1){
                if(x==y) break;
                ++x; ++cnt;
            }
        }else{
            x=0-x;
            ++cnt;
            while(1){
                if(abs(x)==abs(y)) break;
                ++x; ++cnt;
            }
            ++cnt;
        }
    }else if(x<0 && y>=0){
        if(abs(x)<=abs(y)){
            x=0-x;
            ++cnt;
        }
        while(1){
            if(abs(x)==abs(y)) break;
            ++x; ++cnt;
        }
        if(x!=y) ++cnt;
    }else if(x>=0 && y<0){
        if(abs(x)<abs(y)){
            while(1){
                if(abs(x)==abs(y)) break;
                ++x; ++cnt;
            }
            ++cnt;
        }else{
            x=0-x;
            ++cnt;
            while(1){
                if(x==y) break;
                ++x; ++cnt;
            }    
        }
    }
    cout << cnt << "\n";
    return 0;
}   

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N;
  for(int i = 0; i < N; i++) {
    int x; cin >> x;
    if(x % 2 == 0) {
      if(x % 3 != 0 && x % 5 != 0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    
    string s;
    cin >> s;
    
    for(int i = 0; i < n; i++) {
        if(i == k - 1) {
            switch (s[i]) {
                case 'A': cout << "a"; break;
                case 'B': cout << "b"; break;
                default : cout << "c"; break;
            }
        }
        else {
            cout << s[i];
        }
    }
    cout << endl;
    
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  
  vector<int> a(N, 0);
  for(int i = 0; i < N; i++)
  {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int ans = 0;
  if(N % 2 == 0)
  {
    for(int i = 0; i < N / 2; i++)
    {
      ans += a.at(i * 2) - a.at(i * 2 + 1);
    }
    cout << ans << endl;
    return 0;
  }
  else
  {
    for(int i = 0; i < (N - 1) / 2; i++)
    {
      ans += a.at(i * 2) - a.at(i * 2 + 1);
    }
    ans += a.at(N - 1);
    cout << ans << endl;
    return 0 ;
  }
}

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

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

    for (int i=1; i<10; i++) {
        for (int j=9; j>0; j--) {
            if (i*j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n,c = gets.split.map(&:to_i)
sushi = []
n.times do
  sushi << gets.split.map(&:to_i)
end

dirr,dirl = [0],[0]
backr,backl = [0],[0]
maxr,maxl = 0,0
maxbr,maxbl = 0,0

cur,back,prev = 0,0,0
sushi.each do |x,v|
  cur += v-(x-prev)
  back += v-(x-prev)*2
  maxr = cur if cur > maxr
  maxbr = back if back > maxbr
  dirr << maxr
  backr << maxbr
  prev = x
end

cur,back,prev = 0,0,c
sushi.reverse.each do |x,v|
  cur += v-(prev-x)
  back += v-(prev-x)*2
  maxl = cur if cur > maxl
  maxbl = back if back > maxbl
  dirl << maxl
  backl << maxbl
  prev = x
end
ans = 0
(n+1).times do |i|
  t = dirr[i] + backl[n-i]
  u = backr[i] + dirl[n-i]
  ans = [ans,t,u].max
end
p [maxr,maxl,ans].max

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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  for (int i = 0; i < N; i++) cin >> x[i];
  for (int i = 0; i < M; i++) cin >> y[i];
  bool flag;
  for (int Z = X + 1; Z <= Y; Z++) {
    flag = true;
    for (int i = 0; i < N; i++) if (x[i] >= Z) flag = false;
    for (int i = 0; i < M; i++) if (y[i] < Z) flag = false;
    if (flag) break;
  }
  if (flag) cout << "No War" << endl; else cout << "War" << endl;
  return 0;
}

Measured memory_bytes: 256
mo=10^9+7
main=do
 [x,y]<-map read.words<$>getLine
 let n=div(2*y-x)3
 let m=div(2*x-y)3
 print$if n>=0&&m>=0&&mod(x+y)3==0 then c(n+m)n 1 1 else 0
c a 0 x y=x*(power y$mo-2)`mod`mo
c a b x y=c(a-1)(b-1)(x*a`mod`mo)(y*b`mod`mo)
power a n
 |n==0=1
 |n`mod`2==0=power(a*a`mod`mo)(div n 2)
 |True=a*(power a(n-1))`mod`mo

Measured memory_bytes: 121468
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
long long x,res,cnt;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>x;
	res=100;
	while(res<x){
		res+=(res/100);
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);


  int N; cin >> N;
  int k; cin >> k;
  int ans=0;
  vector<int> x(N); rep(i, 0, N){ cin >> x[i];ans+=min(x[i],k-x[i])*2; }
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>

static bool primes[1000010];

int main()
{
    long long n, ans = 0, ip = 2;
    std::cin >> n;
    bool one = n == 1;
    long long size = std::sqrt(n) + 10;
    long long div, cp;
    bool test = true;
    while (n != 1 && ip < size) {
        if (test) {
            div = ip;
            while (div <= n && n % div == 0) {
                n /= div;
                div *= ip;
                ans++;
            }
            while (n % ip == 0) {
                n /= ip;
            }
        }
        for (long long i = ip; i < size; i += ip) {
            primes[i] = true;
        }
        cp = ip;
        for (long long i = ip + 1; i < size; i++) {
            if (!primes[i]) {
                ip = i;
                test = n % i == 0;
                break;
            }
        }
        if (cp == ip) {
            break;
        }
    }

    if (one) {
        std::cout << "0\n";
    } else if (ip == cp) {
        if (n == 1) {
            std::cout << "1\n";
        } else {
            std::cout << ans + 1 << "\n";
        }
    } else {
        std::cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 4164
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string s, a, b, c;
    a = "Sunny";
    b = "Cloudy";
    c = "Rainy";

    cin >> s;
    if(s == a){
        cout << b << endl;
    }
    if(s == b){
        cout << c << endl;
    }
    if(s == c){
        cout << a << endl;
    }    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define drep(i,cc,n) for(int i=cc;i>n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    ll n,k;
    cin>>n>>k;
    vector<int> a(n);
    vector<int> visited(n,-1);
    rep(i,0,n){
        cin>>a[i];
        a[i]--;
    }
    ll num = 0;
    ll now = 0;
    while(visited[now]==-1 && num<k){
        visited[now] = num;
        now = a[now];
        num++;
    }
    k -= visited[now];
    int loop = num - visited[now];
    rep(i,0,k % loop) now = a[now];
    cout<<now+1<<endl;
    return 0;
}

Measured memory_bytes: 4780
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 const double PI=3.1415927;
 
 int main()
 {
   double arr[1000+5][2];
   double alpha=0;
   double x,y;
   x=y=0;
   double unit=1;
   for(int i=0;i<1005;i++)
   {
     arr[i][0]=x+unit*cos(alpha);
     arr[i][1]=y+unit*sin(alpha);
     double change=atan2(arr[i][1],arr[i][0]);
     //cout<<arr[i][0]<<" "<<arr[i][1]<<endl;
     //cout<<change<<endl;
     alpha=change+PI/2;
     x=arr[i][0];
     y=arr[i][1];
   }
   int N;
   while(cin>>N&&(N!=-1))
   {
     printf("%.2lf\n%.2lf\n",arr[N-1][0],arr[N-1][1]);                   
   }
   //while(1);
   return 0; 
 }

 
  

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

#define MAX 3010
int N,S,A[MAX];
const ll mod = 998244353LL;

ll dp[MAX][MAX][3];

ll f(int L,int R) {
  ll ret = 0;
  int len = R - L + 1;
  rep(i,(1<<len)) {
    int sum = 0;
    rep(j,len) {
      if( (i>>j) & 1 ) {
	sum += A[L+j];
      }
    }
    if( sum == S ) ++ret;
  }
  return ret;
}

ll bf() {
  ll ans = 0;
  rep(L,N) {
    REP(R,L,N) {
      ans += f(L,R);
    }
  }
  return ans;
}

void solve() {
  //cout << "Answer : " << bf() << endl;
  rep(i,N) dp[i][0][0] = 1LL;
  rep(i,N) {
    rep(j,S+1) {
      // use
      if( j + A[i] <= S ) {
	// t = 0
	( dp[i+1][j+A[i]][1] += dp[i][j][0] ) %= mod;
	// t = 1
	( dp[i+1][j+A[i]][1] += dp[i][j][1] ) %= mod;
	( dp[i+1][j+A[i]][2] += dp[i][j][1] ) %= mod;
	// t = 2
      }
      // dont
      // t = 0
      ( dp[i+1][j][1] += dp[i][j][0] ) %= mod;
      // t = 1
      ( dp[i+1][j][1] += dp[i][j][1] ) %= mod;
      ( dp[i+1][j][2] += dp[i][j][1] ) %= mod;
    }
    /*
    cout << "** (" << i << ") fin" << endl;
    rep(j,S+1) {
      rep(k,3) {
	if( dp[i+1][j][k] != 0 ) {
	  cout << "dp[" << i+1 << "][" << j << "][" << k << "] = " << dp[i+1][j][k] << endl;
	}
      }
    }
    */
  }
  ll ans = 0;
  rep(i,N) if( A[i] == S ) ++ans;
  REP(i,1,N+1) {
    ( ans += dp[i][S][2] ) %= mod;
    //cout << i << "-th: " << dp[i][S][2] << endl;
  }
  cout << ans << endl;
}

int main() {
  cin >> N >> S;
  rep(i,N) cin >> A[i];
  solve();
  return 0;
}


Measured memory_bytes: 211968
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

string S;

int main()
{
	cin >> S;
	if (S.size() == 1) {
		cout << -1 << " " << -1 << endl;
		return 0;
	}
	if (S.size() == 2) {
		if (S[0] == S[1]) cout << 1 << " " << 2 << endl;
		else cout << -1 << " " << -1 << endl;
		return 0;
	}

	int ans = -1;
	rep(i,0,S.size()-2) {
		int cnt = 0;
		if (S[i] == S[i+1]) cnt++;
		if (S[i] == S[i+2]) cnt++;
		if (S[i+1] == S[i+2]) cnt++;
		if (cnt) {
			ans = i+1;
			break;
		}
	}
	if (ans == -1) cout << -1 << " " << -1 << endl;
	else cout << ans << " " << ans+2 << endl;
 	return 0;
}

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

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string s;
	cin >> s;
	cout << s.substr(0, s.length() - 8) << "\n";

	return 0;
}



Measured memory_bytes: 256
import copy
import sys
import math

def main():
	n,m = map(int,input().split())
	ab = [list(map(int,input().split())) for _ in range(m)]
	b = {}
	for i in ab:
		try:
			b[i[0]].append(i[1])
		except:
			b[i[0]] = [i[1]]
		try:
			b[i[1]].append(i[0])
		except:
			b[i[1]] = [i[0]]
	ab = copy.deepcopy(b)
	for i in ab[1]:
		if(n in ab[i]):
			print('POSSIBLE')
			sys.exit()
	print('IMPOSSIBLE')


def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()



Measured memory_bytes: 207432
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>

#define rep(i,x) for(ll i=0;i<(int)(x);i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> v;

    for(ll i=1; i*i<=n; i++){
        if(n % i == 0){
            v.push_back(i);
        }
    }

    ll ans = 0;
    rep(i, v.size()){
        ll p = v[i];
        ll m = n/v[i]-1;
        if(p < m) ans += m;
    }

    cout << ans;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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);
    int i, j;
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 10);
const int OFFSET = 302;

int n, m;
string t[MAXN];

void read()
{
	cin >> n >> m;
	for(int i = 0; i < n; i++)
		cin >> t[i];
}

int rs[MAXN][MAXN], cs[MAXN][MAXN];
vector<int> on_row[MAXN], on_col[MAXN];

void solve()
{
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			if(t[i][j] == '#')
			{
				int x = i + j + 3, y = i - j + OFFSET + 3;
				on_col[y].push_back(x);
				on_row[x].push_back(y);
				rs[x][y] = 1;
				cs[x][y] = 1;
			}

	for(int i = 0; i < MAXN; i++)
	{
		sort(on_col[i].begin(), on_col[i].end());
		sort(on_row[i].begin(), on_row[i].end());
	}

	for(int i = 1; i < MAXN; i++)
		for(int j = 0; j < MAXN; j++)
			cs[i][j] += cs[i - 1][j];

	for(int i = 0; i < MAXN; i++)
		for(int j = 1; j < MAXN; j++)
			rs[i][j] += rs[i][j - 1];

	int64_t answer = 0;
	for(int rw = 0; rw < MAXN; rw++)
		for(int p = 0; p < (int)on_row[rw].size(); p++)
			for(int q = p + 1; q < (int)on_row[rw].size(); q++)
				for(int d = -1; d <= 1; d += 2)
				{
					int x = rw + d * (on_row[rw][q] - on_row[rw][p]);
					if(x >= 0 && x < MAXN) 
						answer += rs[x][on_row[rw][q]] - rs[x][on_row[rw][p] - 1];
				}
	
	for(int cl = 0; cl < MAXN; cl++)
		for(int p = 0; p < (int)on_col[cl].size(); p++)
			for(int q = p + 1; q < (int)on_col[cl].size(); q++)
				for(int d = -1; d <= 1; d += 2)
				{
					int x = cl + d * (on_col[cl][q] - on_col[cl][p]);
					if(x >= 0 && x < MAXN) 
						answer += cs[on_col[cl][q] - 1][x] - cs[on_col[cl][p]][x];
				}

	cout << answer << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
const int P = 998244353;
int n;
struct Point
{
    int x, y;
} pt[1007];
int ep = 0, f[1007], sz[1007];
int getfa(int x) {
    while (x != f[x])
        x = f[x] = x[f][f];
    return x;
}
struct Edge {
    int a, b;
    int v;
    bool operator<(const Edge &e) const { return v < e.v; }
    void uni(){
        int x = getfa(a), y = getfa(b);
        if (x != y)
            f[x] = y, sz[y] += sz[x];
    }
}E[207 * 207];
int gcd(int a, int b){
    return b ? gcd(b, a % b) : a;
}
int pw[1007], ans;
int main(){
    scanf("%d", &n);
    pw[0] = 1;
    for (int i = 1; i <= n; ++i)
        pw[i] = pw[i - 1] * 2 % P;
    ans = (pw[n] - n - 1) % P;
    for (int i = 0; i < n; ++i)
        scanf("%d%d", &pt[i].x, &pt[i].y);
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < i; ++j)
        {
            int x = pt[i].x - pt[j].x, y = pt[i].y - pt[j].y;
            int g = gcd(x, y);
            x /= g, y /= g;
            if (!x)
                y = 1;
            if (!y)
                x = 1;
            if (x < 0)
                x = -x, y = -y;
            E[ep++] = (Edge){i, j, x * 30000 + y};
        }
    }
    sort(E, E + ep);
    for (int i = 0, j = 0; i < ep; i = j)
    {
        for (int a = 0; a < n; ++a)
            sz[f[a] = a] = 1;
        for (; j < ep && E[i].v == E[j].v; E[j++].uni())
            ;
        for (int a = 0; a < n; ++a)
            if (f[a] == a && sz[a] > 1)
                ans = (ans - pw[sz[a]] + sz[a] + 1) % P;
    }
    printf("%d\n", (ans % P + P) % P);
    return 0;
}

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

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<string> S(N);
    vector<int> P(N);
    for(int i=0;i<N;i++){
        cin>>S[i]>>P[i];
    }
    map<pair<string,int>,int> dict;
    for(int i=0;i<N;i++){
        pair<string,int> Pair=make_pair(S[i],-P[i]);
        dict[Pair]=i+1;
    }
    
    for(auto x:dict){
        cout<<x.second<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())

for i in range(N):
    b = int(input())
    for j in range(3):
        A[j] = ["$" if num == b else num for num in A[j]]

if ["$"]*3 in A:
    print("Yes")
elif any( [A[j][i] for j in range(3)] == ["$"]*3 for i in range(3) ):
    print("Yes")
elif [A[0][0], A[1][1], A[2][2]] == ["$"]*3 \
            or [A[0][2], A[1][1], A[2][0]] == ["$"]*3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import copy
n,k,c=map(int,input().split())
s=list(input())

Left=[0]*k
Leftcnt=0
Right=[0]*k
Rightcnt=0

Rest=['x']*c

#前から
L=copy.deepcopy(s)
for i in range(n):
    if Leftcnt==k:
        break
    if L[i]=='o':
        Left[Leftcnt]=i+1
        Leftcnt+=1
        if i+c<=n:
            L[i+1:i+c+1]=Rest

#後ろから
R=copy.deepcopy(s)
for j in range(n):
    if Rightcnt==k:
        break
    if R[-j-1]=='o':
        Right[Rightcnt]=-j+n
        Rightcnt+=1
        if j+c<=n:
            R[-j-c-1:-j-1]=Rest
Right=sorted(Right)
for i in range(k):
    if Left[i]==Right[i]:
        print(Left[i])

Measured memory_bytes: 25928
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
//typedef long long int;

array<int, 3> c;
ll res = 0;
set<pii> w[3][3];
vector<array<int, 3>> v;

void add(int i, int j) {
  res += v[i][j];
  for (int t = 0; t < 3; ++t) if (t != j) {
    w[j][t].insert(pii(v[i][j] - v[i][t], i));
  }
}

void rem(int i, int j) {
  res -= v[i][j];
  for (int t = 0; t < 3; ++t) if (t != j) {
    w[j][t].erase(pii(v[i][j] - v[i][t], i));
  }
}

void move(int x, int i, int j) {
  rem(x, i);
  add(x, j);
}

int main() {
//std::ios::sync_with_stdio(false);
  scanf("%d%d%d", &c[0], &c[1], &c[2]);
  v.resize(c[0]+c[1]+c[2]);
  for (int i = 0; i < v.size(); ++i) {
    int ma = 0, best = 0;
    for (int j = 0; j < 3; ++j) {
      scanf("%d", &v[i][j]);
      if (ma < v[i][j]) {
        ma = v[i][j];
        best = j;
      }
    }
    add(i, best);
  }
  for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) if (i != j) while (w[i][j].size() > c[i] && w[j][i].size() < c[j]) {
    int k = 3 - i - j;
    int val1 = w[i][j].begin()->first;
    int val2 = !w[k][j].empty() ? w[i][k].begin()->first + w[k][j].begin()->first : 2e9;
    if (val1 <= val2) {
      move(w[i][j].begin()->second, i, j);
    } else {
      int xik = w[i][k].begin()->second;
      int xkj = w[k][j].begin()->second;
      move(xik, i, k);
      move(xkj, k, j);
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 10752
package main

import (
	"bufio"
	"errors"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	a := sc.Text()
	list := []int{}
	stack := strings.Split(a, " ")
	for _, s := range stack {
		a, err := strconv.Atoi(s)
		if err != nil {
			i, j, err := pop2num(list)
			k, err := calc(i, j, s)
			if err != nil {
				log.Fatal(err)
			}
			list = append(list[:len(list)-1], list[len(list):]...)
			list = append(list[:len(list)-1], list[len(list):]...)
			list = append(list, k)
		} else {
			list = append(list, a)
		}
	}
	fmt.Println(list[len(list)-1])
}

func calc(a int, b int, ope string) (int, error) {
	switch ope {
	case "+":
		return a + b, nil
	case "-":
		return a - b, nil
	case "*":
		return a * b, nil
	case "/":
		return a / b, nil
	default:
		return 0, errors.New("there is an error")
	}
}

func pop2num(list []int) (int, int, error) {
	if len(list) < 2 {
		return 0, 0, errors.New("this list is invalid")
	}
	var a, b int
	b = list[len(list)-1]
	a = list[len(list)-2]
	return a, b, nil
}


Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define dl double
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define pr(n) cout << fixed << setprecision(n)
#define ci(n) cin >> n
#define ci2(n, o) cin >> n >> o
#define ci3(n, o, p) cin >> n >> o >> p
#define co(n) cout << n << endl

int main() {
  int r;
  ci(r);
  co(3 * r * r);
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

vector<vector<int> > bfs(vector<vector<int> > valid, int x, int y){
    vector<vector<int> > dist(valid.size(), vector<int>(valid[0].size(), INTINF));
    queue<tuple<int,int,int>> Q;
    tuple<int,int,int> t;
    int d;
    if (valid[x][y])Q.push(make_tuple(x, y, 0));
 
    while(!Q.empty()){
        t = Q.front();Q.pop();
        x = get<0>(t);y = get<1>(t);d = get<2>(t);
        if (dist[x][y] <= d)continue;
        dist[x][y] = d;
        for (int i=0;i<4;i++){
            if (0<=x+DX[i] && x+DX[i]<valid.size() && 0<=y+DY[i] && y+DY[i]<valid[0].size()){
                if (!valid[x+DX[i]][y+DY[i]])continue;
                int d_next = d+1;
                
                if (dist[x+DX[i]][y+DY[i]]>d_next)
                    Q.push(make_tuple(x+DX[i],y+DY[i],d_next));
            }
        }
    }
    return dist;
}

void print_vector(vector<vector<int> > vector){
    for (int i = 0; i < vector.size(); i++){
        for (int j = 0; j < vector[i].size(); j++)
            cout << vector[i][j] << " ";
        cout << endl;
    }
}

int main(){
    int H,W;
    int cnt_invalid = 0;
    cin >> H >> W;
    string S;
    vector<vector<int> > valid(H, vector<int> (W, 1) );
    for (int h=0; h<H;h++){
        cin >> S;
        for (int w=0; w<W; w++){
            if (S[w]=='#'){
                valid[h][w]=0;
                cnt_invalid++;
            }
        }
        
    }
    //print_vector(valid);
    vector<vector<int> > dist(H, vector<int> (W) );
    dist = bfs(valid,0 ,0);
    if (dist[H-1][W-1]==INTINF)cout << "-1" << endl;
    else cout << H*W-cnt_invalid-dist[H-1][W-1]-1 << endl;
}


Measured memory_bytes: 256
s = []
ans = 0
for i in range(5):
    n = int(input())
    m = n % 10
    ans += n
    if m != 0:
        s.append(m)
s.sort()
for i in range(len(s)):
    if i != 0:
        c = 10 - s[i]
        ans += c
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    long temp;
    long c = a;
    c *= b;
    while((temp = a%b)!=0) {
      a = b;
      b = temp;
    }
    System.out.println((long)(c/b));
  }
}


Measured memory_bytes: 35656
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vct vector<ll>
#define umap unordered_map<ll,ll>
#define mpp map<ll,ll>
#define stt set<ll>
#define pir pair<ll,ll>
#define vpp vector<pair<ll,ll> >

ll poww(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
void prt(vector<string> v)
{
    for(ll i=0;i<v.size();i++)cout<<v[i]<<" ";
    cout<<"\n";
}
vct siev(ll n)
{
    vct ans;ll ar[n+1];
    memset(ar,-1,sizeof(ar));ar[0]=0;ar[1]=0;
    for(ll i=2;i<=n;i++)
    {if(ar[i]==-1){ans.push_back(i);ar[i]=1;for(ll j=2*i;j<=n;j=j+i)ar[j]=0;}}
    return ans;
}
ll isprime(ll n)
{
    if(n==1||n==0)return 0;
    for(ll i=2;i<=sqrt(n);i++)if(n%i==0)return 0;
    return 1;
}
ll etf(ll n) 
{
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)n /= i;
            result -= result / i;
        }
    }
    if(n > 1)result -= result / n;
    return result;
}
vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    // sort(ans.begin(),ans.end());
    return ans;
}
ll cnd(ll n){ll cnt=0;while(n){cnt++;n=n/10;}return cnt;}
ll t,m,n,d,q,p;
ll t1,t2,k;
ll mod=1000000007;
ll ans=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    vct dv=divsors(n);
    ll mn=LLONG_MAX;
    for(ll i=0;i<dv.size();i++)
    {
        ll ii=dv[i];
        ll jj=n/ii;
        mn=min(mn,ii+jj-2);
    }
    cout<<mn<<"\n";
    
}

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

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

    int n;
    cin >> n;
    double t, a;
    cin >> t >> a;

    double mini = 1e9;
    int idx = 1e9;
    for(int i = 0; i < n; i++){
        int h;
        cin >> h;
        double ave = t - h * 0.006;
        mini = min(mini, abs(a - ave));
        if(mini == abs(a - ave)){
            idx = i;
        }
    }

    cout << idx + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans;
int N, K;
char S[100005];

int main(void) {
    scanf("%d %d", &N, &K);
    scanf("%s", S);

    int reverse = 0;

    REP(i, 1, N) {
    	if (S[i-1] != S[i]) {
    		reverse++;
    		S[i] = S[i-1];
    		i++;
    		while (S[i-1] != S[i] && i < N) {
    			S[i] = S[i-1];
    			i++;
    		}
    	}
    	if (reverse == K) break;
    }

    //printf("%s\n", S);

    REP(i, 0, N-1) if (S[i+1] == S[i]) ans++;
  
    printf("%d\n", ans);

	return 0;
}


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

using namespace std;

int m[50][50]={};
int w,h;
int cnt;

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

void fanc(int y,int x){
	m[y][x]=0;
	int ny,nx;
	for(int i=0;i<8;i++){
		ny = y+dy[i];
		nx = x+dx[i];
		if(ny>=0&&nx>=0&&ny<h&&nx<w&&m[ny][nx]==1){
			fanc(ny,nx);
		}
	}
}

int main(){
	
	
	while(1){
		
		cnt=0;
		cin >> w >> h;
		if(w==0) break;
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> m[i][j];
			}
		}
		
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(m[i][j]!=0){
					cnt++;
					fanc(i,j);
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}
	


Measured memory_bytes: 3092