akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}

	// sum := make([]int, n+1)
	// for i := 0; i < n; i++ {
	// 	sum[i+1] = sum[i] + slice[i]
	// }

	// cnt1 := 0
	// tmp1 := sum[1:]
	// for i := 0; i < n; i++ {
	// 	if i%2 == 0 {
	// 		if tmp1[i] <= 0 {
	// 			cnt1 += abs(1 - tmp1[i])
	// 			tmp1[i] = 1
	// 		}
	// 	} else {
	// 		if tmp1[i] >= 0 {
	// 			cnt1 += abs(-1 - tmp1[i])
	// 			tmp1[i] = -1
	// 		}
	// 	}
	// }

	// fmt.Println(cnt1)

	// cnt2 := 0
	// tmp2 := sum[1:]
	// for i := 0; i < n; i++ {
	// 	if i%2 == 0 {
	// 		if tmp2[i] >= 0 {
	// 			cnt2 += abs(-1 - tmp2[i])
	// 			tmp2[i] = -1
	// 		}
	// 	} else {
	// 		if tmp2[i] <= 0 {
	// 			cnt2 += abs(1 - tmp2[i])
	// 			tmp2[i] = 1
	// 		}
	// 	}
	// }

	// fmt.Println(cnt2)

	ans1 := solve(slice, 1)
	ans2 := solve(slice, 0)
	fmt.Println(min(ans1, ans2))
}

func solve(a []int, r int) int {
	cnt := 0
	sum := 0

	for i := 0; i < len(a); i++ {
		if i%2 == r {
			if a[i]+sum <= 0 {
				cnt += abs(1 - a[i] - sum)
				sum = 1
			} else {
				sum += a[i]
			}
		} else {
			if a[i]+sum >= 0 {
				cnt += abs(-1 - a[i] - sum)
				sum = -1
			} else {
				sum += a[i]
			}
		}
	}
	return cnt
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -1 * a
	}
	return a
}


Measured memory_bytes: 3072
N = int(input())
ans = 0
for i in range(1, N + 1):
    n = N // i  # 項数n
    cnt = (n * (2 * i + (n - 1) * i)) // 2  # 初項i, 項数n の等差数列の和の公式
    ans += cnt
print(ans)

Measured memory_bytes: 9124
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {

	vector<string> tenki(3);
	tenki[0] = "Sunny";
	tenki[1] = "Cloudy";
	tenki[2] = "Rainy";

	string S;

	cin >> S;

	if(S==tenki[0])
	{
		cout << tenki[1];
	}else if (S == tenki[1]) {
		cout << tenki[2];
	}else {
		cout << tenki[0];
	}

	return 0;
}

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

int main()
{
    int n, ans = 1; cin >> n;
    string s; cin>> s;
    for(int i = 1; i < n; i++){
        if(s.at(i) != s.at(i - 1)) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

int cal(int a, int b, char op){
  switch(op){
    case '+':
      return a + b;
    case '-':
      return a - b;
    case '*':
      return a * b;
    case '/':
      return a / b;
    default :
    return 0;
  };
}

int main(){
  int a, b;
  char op;
  vector<int> v;
  while(cin >> a >> op >> b && op != '?'){
    v.push_back(cal(a, b, op));
  }
  for(int i=0;i<(int)v.size();i++){
    cout << v[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
n = int(input())
a = list(map(int,input().split()))
m = [0] * n
total=sum(a)
m[0] = total - 2 * sum(a[1::2])
for i in range(1,len(a)):
  m[i] = 2*a[i-1] - m[i-1]

for mi in m[:-1]:
  print(mi,end=' ')
print(m[-1],end='')        

Measured memory_bytes: 14092
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

n, m = LI()
c = LI()
c = sorted(c)

dp = [n+1]*(n+1)
dp[0] = 0

for i in range(n+1):
    for coin in c:
        if (i+coin <= n) and (dp[i+coin] > dp[i]+1):
            dp[i+coin] = dp[i]+1

print(dp[n])


Measured memory_bytes: 9760
#include <bits/stdc++.h>
using namespace std;
class finite_field {
  const int md;
  const int sz;
  vector<int> fct, fnv;
  void init () {
    if (sz) {
      fct[0] = 1;
      for (int i = 1; i < sz; i++) fct[i] = prod(fct[i - 1], i);
      fnv[sz - 1] = inv(fct[sz - 1]);
      for (int i = sz - 1; i >= 1; i--) fnv[i - 1] = prod(fnv[i], i);
    }
  }
  public:
    finite_field(
        const int md,
        const int init_factorial_size = 0,
        const int init_power_size = 0
      ) :
      md(md), sz(init_factorial_size),
      fct(sz), fnv(sz)
      {
        init();
      }
    inline void add (int& a, const int b) const {
      a += b;
      if (a >= md) a -= md;
    }
    inline void sub (int& a, const int b) const {
      a -= b;
      if (a < 0) a += md;
    }
    template<class... A> inline int sum (A... args) const {
      int ret = 0;
      for (int a : initializer_list<int>{args...}) {
        add(ret, a);
      }
      return ret;
    }
    inline int dif (int a, int b) const {
      sub(a, b);
      return a;
    }
    template<class... A> inline int prod (A... args) const {
      long long ret = 1;
      for (int a : initializer_list<int>{args...}) {
        ret *= a;
        ret %= md;
      }
      return (int)ret;
    }
    void mul (int& a, int b) const {
      a = prod(a, b);
    }
    inline int inv (int a) const {
      a %= md; if (a < 0) a += md;
      int b = md, u = 0, v = 1;
      while (a) {
        int t = b / a;
        b -= a * t; swap(a, b);
        u -= v * t; swap(u, v);
      }
      assert(b == 1);
      if(u < 0) u += md;
      return u;
    }
    inline int quat (int a, int b) const {
      return prod(a, inv(b));
    }
    inline void div (int& a, int b) const {
      a = quat(a, b);
    }
    inline int pow (int a, long long b) {
      int ret = 1;
      for (; b; b >>= 1) {
        if (b & 1) mul(ret, a);
        a = prod(a, a);
      }
      return ret;
    }
    inline int binom (int n, int k) const {
      assert(0 <= n && n < sz);
      if (k < 0 || n < k) return 0;
      return prod(fct[n], fnv[k], fnv[n - k]);
    }
};
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int>> dp(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dp[i][j] = a[i] > a[j] ? 1 : 0;
    }
  }
  finite_field fld(1e9 + 7);
  int inv2 = fld.inv(2);
  int coeff = fld.pow(2, q);
  while (q--) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    auto half = [&] (int& a, int& b) -> void {
      fld.add(a, b);
      fld.mul(a, inv2);
      b = a;
    };
    half(dp[x][y], dp[y][x]);
    for (int z = 0; z < n; z++) if (z != x && z != y) {
      half(dp[x][z], dp[y][z]);
      half(dp[z][x], dp[z][y]);
    }
  }
  int ret = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      fld.mul(dp[i][j], coeff);
      fld.add(ret, dp[i][j]);
    }
  }
  cout << ret << endl;
  return 0;
}

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

using namespace std;

int n, k, r, s, p;
string t;

char move(char c)
{
    if (c == 'r')
        return 'p';

    if (c == 'p')
        return 's';

    if (c == 's')
        return 'r';

    return '\0';
}

char inverse(char c)
{
    if (c == 'r')
        return 's';

    if (c == 'p')
        return 'r';

    if (c == 'r')
        return 'p';

    return '\0';
}

int score(char c)
{
    if (c == 'r')
        return r;

    if (c == 's')
        return s;

    if (c == 'p')
        return p;

    return 0;
}

int main()
{
    cin >> n >> k >> r >> s >> p >> t;

    // dp[i]: score after i'th move
    string moves = "";

    int ans = 0;

    for (int i = 0; i < k; i++)
    {
        moves += move(t[i]);
        ans += score(moves[i]);
    }

    for (int i = k; i < n; i++)
    {
        moves += move(t[i]);

        if (moves[i] != moves[i-k])
            ans += score(moves[i]);
        else
        {
            if (i + k < n)
            {
                if (move(t[i+k]) == t[i])
                {
                    moves[i] = inverse(t[i]);
                }
                else
                {
                    moves[i] = t[i];
                }
            }
        }
    }

    // cout << t << "\n";
    // cout << moves << "\n";
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main () {
    // paper (p) <= rock (g)

    int i;
    string s;
    set<string> ss;
    cin >> i;
    while (i--) {
        //cout << "inserting : " << s << endl;
        cin >> s;
        ss.insert(s);
    }

    cout << ss.size() << endl;
    return 0;
}


Measured memory_bytes: 19116
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var N int
var M int
var X []int

func main() {
	N = nextInt()
	M = nextInt()
	X = nextInts(M)
	if N >= M {
		fmt.Println(0)
		return
	}
	sort.Ints(X)
	distance := make([]int, M-1)
	for i := 1; i < M; i++ {
		distance[i-1] = X[i] - X[i-1]
	}
	sort.Ints(distance)
	ans := 0
	for i := 0; i < M-N; i++ {
		ans += distance[i]
	}
	fmt.Println(ans)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  string s; cin >> s;
  ll sum = 0;
  rep(i, s.size()) sum += ctoi(s.at(i));
  if (sum%9) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

template <typename T>
using Vec = std::vector<T>;

int main() {
	std::string s;
	int k;
	std::cin >> s >> k;

	//if (s.size() == 1) {
	//	std::cout << (k == 1 ? s : "0") << std::endl;
	//	return 0;
	//}
	//if (s.size() == 2) {
	//	std::cout << (
	//		k == 2 ? (s[0] - '0' - 1) * 9 + (s[1] - '0') :
	//		k == 1 ? (s[0] - '0') + 9 :
	//		0
	//		) << std::endl;

	//	return 0;
	//}

	Vec<Vec<Vec<int>>> dp(s.size() + 1, Vec<Vec<int>>(2, Vec<int>(k + 1)));
	
	dp[0][1][0] = 1;
	for (int i = 1; i <= s.size(); ++i)
		dp[i][0][0] = 1;

	for (int i = 1; i <= s.size(); ++i) {
		for (int j = 1; j <= i && j <= k; ++j) {
			int x = s[i - 1] - '0';

			dp[i][0][j] = dp[i - 1][0][j] + dp[i - 1][0][j - 1] * 9;
			if (x != 0) {
				dp[i][0][j] += dp[i - 1][1][j - 1] * (x - 1) + dp[i - 1][1][j];
				dp[i][1][j] = dp[i - 1][1][j - 1];
			}
			else
				dp[i][1][j] = dp[i - 1][1][j];
		}
	}

	std::cout << dp[s.size()][0][k] + dp[s.size()][1][k] << std::endl;
}

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

int gcd(int a, int b){
    if(a*b==0){
        if(a==0){
            return b;
        }else{
            return a;
        }
    }else{
        int r;
        while(b!=0){
            r = a % b;
            a = b;
            b = r;
            
        }
        return a;
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> args(n);
    for(int i=0; i<n; i++){
        cin >> args[i];
    }
    // args[0]=7;
    // args[1]=6;
    // args[2]=8;

    vector<int> l(n+1);
    vector<int> r(n+1);
    l[0] = 0;
    for(int i=0; i<n; i++){
        l[i+1] = gcd(l[i], args[i]);
    }
    r[n] = 0;
    for(int i=0; i<n; i++){
        r[n-i-1] = gcd(r[n-i], args[n-i-1]);
    }

    int max = 0;
    for(int i=0; i<n; i++){
        int divisor = gcd(l[i], r[i+1]);
        if(divisor>max){max = divisor;}
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using Matrix = std::vector<std::vector<int>>;

std::vector<int> solve(int n, int x, int y)
{
  Matrix m;
  m.reserve(n);
  for (int i = 0; i < n - 1; ++i) {
    m.push_back(std::vector<int>(n));
    auto& row = m.back();
    for (int j = i + 1; j < n; ++j) {
      row.at(j) = j - i;
    }
  }

  for (int i = 0; i < x; ++i) {
    auto& row = m.at(i);
    for (int j = y - 1; j < n; ++j) {
      row.at(j) = row.at(x - 1) + 1 + j - (y - 1);
    }
    for (int j = y - 2; j >= i + 1; --j) {
      auto new_d = row.at(x - 1) + (y - 2) - j + 2;
      auto& old = row.at(j);
      if (old <= new_d) break;
      old = new_d;
    }
  }
  for (int i = x; i < y - 1; ++i) {
    auto& row = m.at(i);
    for (int j = y - 2; j >= i + 1; --j) {
      auto new_d = row.at(x - 1) + (y - 2) - j + 2 + i - x + 1;
      auto& old = row.at(j);
      if (old <= new_d) break;
      old = new_d;
    }
    auto new_d = row.at(x - 1) + 1 + i - x + 1;
    if (new_d < row.at(y - 1)) {
      for (int j = y - 1; j < n; ++j) {
        row.at(j) = new_d + j - (y - 1);
      }
    }
  }

  std::vector<int> result(n);
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      result.at(m[i][j]) += 1;
    }
  }
  return std::vector<int>(result.begin() + 1, result.end());
}

int main()
{
  int n, x, y;
  std::cin >> n >> x >> y;

  std::cout << std::setprecision(20);

  auto v = solve(n, x, y);
  for (auto x : v) {
    std::cout << x << std::endl;
  }
}


Measured memory_bytes: 16000
#include<iostream>
using namespace std;
const int N = 2e5 + 5;
int n,m, siz[N] , par[N];
int dsu_parent(int node){
    if(node==par[node]){
        return node;
    }
    return par[node] = dsu_parent(par[node]);
}
void dsu_union(int a,int b){
    a = dsu_parent(a);
    b = dsu_parent(b);
    if(a==b)return;
    if(siz[a]<siz[b])swap(a,b);
    par[b]=a;
    siz[a]+=siz[b];
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        par[i]=i;
        siz[i]=1;
    }
    for(int i=1;i<=m;i++){
        int u,v;cin>>u>>v;
        dsu_union(u,v);
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
      	if(i==par[i])ans = max(ans , siz[i] );
    }
    cout<<ans;
}


Measured memory_bytes: 5236
#include <iostream>
#include <math.h>
#include <map>
using namespace std;

int main(){

    long long int a,b,i,q,res,ans=0,j,n;
    cin >> n;
    map< int , int > ar;
    for(i=0;i<n;i++){
        cin >> res;
        ar[res]++;
        ans+=res;
    }
    cin >> q;
    while(q--){
        cin >> a >> b;
        ans += (b-a)*ar[a];
        res=ar[a];
        ar[b]+=res;
        ar[a]=0;
        cout << ans << "\n";
    }
}


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


void lcs( string X, string Y, int m, int n )
{
   int L[m+1][n+1];


   for (int i=0; i<=m; i++)
   {
     for (int j=0; j<=n; j++)
     {
       if (i == 0 || j == 0)
         L[i][j] = 0;
       else if (X[i-1] == Y[j-1])
         L[i][j] = L[i-1][j-1] + 1;
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]);
     }
   }


   int index = L[m][n];


   char lcs[index+1];
   lcs[index] = '\0';

   int i = m, j = n;
   while (i > 0 && j > 0)
   {

      if (X[i-1] == Y[j-1])
      {
          lcs[index-1] = X[i-1];
          i--; j--; index--;
      }


      else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
   }


   cout <<lcs;
}


int main()
{
  string x,y;
  cin>>x>>y;

  int m = x.length();
  int n = y.length();
  lcs(x, y, m, n);
  return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int mod_pow(int x,int y,int m=mod){
	int res=1;
	while(y>0){
		if(y&1)(res*=x)%=m;
		(x*=x)%=m;
		y>>=1;
	}
	return res;
}
vector<int>perm,inv;
void init_perm(){
	int x=1e6+1;perm.resize(x);inv.resize(x);
	perm[0]=1;
	REP(i,x+1)perm[i]=perm[i-1]*i%mod;
	inv[x]=mod_pow(perm[x],mod-2);
	for(int i=x-1;i>=0;i--){
		inv[i]=inv[i+1]*(i+1)%mod;
	}
}
int nCk(int x,int y){
	if(x<y)return 0;
	return perm[x]*inv[x-y]%mod*inv[y]%mod;
}
signed main(){
	init_perm();
	int N,M;cin>>N>>M;
	int ans1=nCk(M,N)*perm[N]%mod;
	int ans2=0;
	rep(i,N+1){
		int j=nCk(N,i)*nCk(M-i,N-i)%mod*perm[N-i];
		if(i%2==0)ans2+=j;
		else ans2-=j;
		(ans2+=mod)%=mod;
	}
	cout<<ans1*ans2%mod<<endl;
}


Measured memory_bytes: 18620
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple{
    private int N, K;
    void Solve(){
        //input
        N = io.Int;
        K = io.Int;
        //cal
        var X = 1;
        for(int i = 0; i < N; ++i){
            if(X < K) X *= 2;
            else X += K;
        }
        //ret
        Console.WriteLine(X);

    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {Solve();io.writeFlush();}
}
class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> s(N);
  int ans = 0;
  rep(i, N) {
    cin >> s[i];
    ans += s[i];
  }
  sort(s.begin(), s.end());
  if(!(ans%10)) {
    bool flag = true;
    rep(i, N) {
      if(s[i]%10) {
        ans -= s[i];
        flag = false;
        break;
      }
    }
    if(flag)
      ans = 0;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int x;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) {
			cout << " " << i;
		}
		else {
			x = i;
			do {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
			} while (x);
		}
	}
	cout << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priotity_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int n,m,a;
bool li[15]={};

int main(){
	cin >> n >> m;
	REP(i,0,m) cin >> a,li[a]=true;
	
	REP(i,n,n*10+1){
		string w=to_string(n);
		bool f=true;
		
		REP(i,0,w.size()) if(li[w[i]-'0']) f=false;
		
		if(f) break;
		n++;
	}
	
	cout << n << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    n, d = map(int, input().split())
    cnt = 0
    for idx in range(n):
        x, y = map(int, input().split())
        if x ** 2 + y ** 2 <= d ** 2:
            cnt += 1
    print(cnt)
  
if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> a;
    a.push_back(0);
    for(int i = 0; i < n; i++) {
        int x; cin >> x;
        a.push_back(x);
    }
    a.push_back(0);

    int d = 0;
    for(int i = 1; i < a.size(); i++) d += abs(a[i] - a[i - 1]);

    for(int i = 1; i <= n; i++) {
        int add = abs(a[i - 1] - a[i + 1]);
        int sub = abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1]);
        int ans = d + add - sub;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
#pragma region atcoder
//#include <atcoder/all>
//using namespace atcoder;
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion

const ll mod = 998244353;
const int inf = 1001001001;
const ll INF = 1001001001001001001;
const int MAX = 2000005;

//using mint = modint998244353;
//These are for segment tree
/*int op(int a, int b){return max(a, b);}
int e(){return -1;}
bool f(int v){ return v < target;}
*/

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

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; }
ll modpow(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}

/*--------------------------------------------------------------------------------------------------------------------------------*/

ll dp[200005];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k; cin >> n >> k;
	vector<int> l(k), r(k);
	for(int i = 0; i < k; i++){
		cin >> l[i] >> r[i];
	}
	dp[1] = 1;
	for(int i = 1; i <= n; i++){
		if(i > 2){
			dp[i] += dp[i - 1];
			dp[i] %= mod;
		}
		for(int j = 0; j < k; j++){
			if(i + l[j] <= 200004){
				dp[i + l[j]] += dp[i];
				dp[i + l[j]] %= mod;
			}
			if(i + r[j] <= 200004) dp[i + r[j] + 1] += (mod - dp[i]) % mod;
		}
	}
	cout << dp[n] % mod << endl;
} 

Measured memory_bytes: 5204
N,M = map(int,input().split())
PrefDB = [ [i] + [int(x) for x in input().split()] for i in range(M)]
PrefDB.sort(key=lambda x:(x[1],x[2]))
counter = 1
pred = 0
for i in range(M):
    if pred != PrefDB[i][1]:
        counter = 1
    PrefDB[i].append(str(1000000000000 + PrefDB[i][1]*1000000 + counter)[1:])
    pred = PrefDB[i][1]
    counter += 1
PrefDB.sort(key=lambda x:x[0])
for i in range(M):
    print(PrefDB[i][-1])

Measured memory_bytes: 34336
K = int(input())
def snuke(n):
  _n = n
  S = n % 10
  while _n:
    _n //= 10
    S += _n % 10
  return n / S
cnt = 0
k = 0
x = 1
sx = 2
while cnt < K:
  a = max(k - 1, 1)
  b = max(k, 1) * 10
  c = int('0' + ('9' * k))
  for i in range(a, b):
    y = x
    sy = sx
    x = i * 10 ** k + c
    sx = snuke(x)
    if sx >= sy:
      print(y)
      cnt += 1
      if cnt >= K:
        break
  k += 1

Measured memory_bytes: 38768
import java.math.BigDecimal;
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

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

    private void run() {
        BigDecimal a = BigDecimal.valueOf(sc.nextLong());
        BigDecimal b = BigDecimal.valueOf(sc.nextDouble());
        System.out.println(a.multiply(b).longValue());
    }
}



Measured memory_bytes: 37680
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

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

void solve(){
    int n,a,b;
    cin>>n>>a>>b;
    vector<int>p(n),v1,v2,v3;
    rep(i,n){
        cin>>p[i];
        if(p[i]<=a)v1.pb(p[i]);
        else if(p[i]>a&&p[i]<=b)v2.pb(p[i]);
        else v3.pb(p[i]);
    }
    cout<<min({v1.size(),v2.size(),v3.size()});
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


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

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
#define MOD 1000000007

using namespace std;

using ll = long long;
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;

typedef stack<ll> llStack;
typedef queue<ll> llQueue;
typedef vector<ll> llVector;
typedef list<ll> llList;

typedef struct S{
  int a;
  int b;
} Object;

int main(){
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  
  
  double a = cos(abs((M_PI*H/6.0+M_PI*M/360.0)-(M_PI*M/30.0)));
  double ans = sqrt(A*A+B*B-2.0*A*B*a);
  
  printf("%.20f\n", ans);
  
}

Measured memory_bytes: 4136
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
const int MOD=100000;
string keta[18]={"","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"};
int main(){
      int n,m,cnt[18];
      while(cin>>m>>n&&(n||m)){
            memset(cnt,0,sizeof(cnt));
            cnt[0]=1;
            REP(i,n){
                  //REP(i,18)cout<<cnt[i]<<" ";cout<<endl;
                  for(int j=17;j>=0;j--){
                        int a=cnt[j]*m;
                        cnt[j]=a%10000;
                        cnt[j+1]+=a/10000;
                  }
            }
            for(int i=17;i>0;i--){
                  if(cnt[i]!=0)cout<<cnt[i]<<keta[i];
            }
            if(cnt[0]!=0)cout<<cnt[0];
            cout<<endl;

      }
}

Measured memory_bytes: 1208
// Solving knapsack problem with DP

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

// input
// n = value of gilt
// W = limit of total weight
// weight[] = weight of each gilt
// value[] = value of each gilt
const int n=3000;
const int W=3000;
int weight[3001], value[3001];

// DP table
int dp[3001][3001];

//------------------------------------------------------------------------------
/// 指定されたDPテーブルの要素はどの金塊の組み合わせで作れるのかを逆算する
/// @param i 使って良い金塊の個数 i番目までの金塊を使える
///        w ナップサックの耐荷重
///        ans 答え,金塊を0:入れない 1:入れる
void DP_OptimalSolution(const int i, const int w,int ans[n]){
    int local_w=w;
    for(int local_i=i-1;local_i>=0;local_i--){
        if (local_w >= weight[local_i] && max(dp[local_i][local_w-weight[local_i]] + value[local_i], dp[local_i][local_w])==dp[local_i][local_w]){
            ans[local_i]=0;
        }
        else if(local_w >= weight[local_i] && max(dp[local_i][local_w-weight[local_i]] + value[local_i], dp[local_i][local_w])==dp[local_i][local_w-weight[local_i]] + value[local_i]){
            ans[local_i]=1;
            local_w=local_w-weight[local_i];
        }
        else if(local_w < weight[local_i]){
            ans[local_i]=0;
        }
    }
}
int main() {
    int x,t;
    cin>>x>>t;
    for(int i=0;i<n;++i){
        cin>>weight[i]>>value[i];
    }
  // init
  for (int w = 0; w <= W; ++w) dp[0][w] = 0;
  // DP table
  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= W; ++w) {
      if (w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      else dp[i+1][w] = dp[i][w];
    }
  }
  //answer
  int a1[n];
  int a2[n];
  int ans1,ans2;
  ans1=0;ans2=0;
  DP_OptimalSolution(x,t,a1);
  for(int i=0;i<n;i++){
    ans1+=a1[i]*value[i];
  }
  // init
  for (int w = 0; w <= W; ++w) dp[0][w] = 0;
  // DP table
  for (int i = 0; i < n; ++i) {
    for (int w = 0; w <= W; ++w) {
      if (w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w]);
      else dp[i+1][w] = dp[i][w];
    }
  }
  DP_OptimalSolution(n,t-1,a2);
  for(int i=0;i<n;i++){
    ans2+=a2[i]*value[i];
  }
  int tmp=0;
  for(int i=0;i<n;i++){
    if((tmp<value[i])&&a2[i]==0){tmp=max(tmp,value[i]);}
  }
  
  cout<<max(tmp+ans2,ans1)<<endl;
  return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};



int main() {
    int n,T;cin>>n>>T;
    vector<pii> x(n);
    rep(i,n)cin>>x[i].first>>x[i].second;
    sort(all(x),[](pii t1, pii t2){return t1.first < t2.first;});
    rep(i,n){
        if(x[i].second<=T) {cout<<x[i].first<<endl;return 0;}
    }
    cout<<"TLE"<<endl;
         
         
    
    
    
    
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int nmax = 100;
int main(){
    int x;
    int n;
    cin >> x >> n;
    int p[nmax];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }

    int answer = x;
    int countup = 0;
    while(countup < 101){
        int answer_small = x-countup;
        int answer_large = x+countup;

        for(int j=0; j<n; j++){
            if(answer_small==p[j]){
                answer_small = -200;
                continue;
            }
        }
        if(answer_small!=-200){
            answer = answer_small;
            break;
        }

        for(int j=0; j<n; j++){
            if(answer_large==p[j]){
                answer_large = -200;
                continue;
            }
        }
        if(answer_large!=-200){
            answer = answer_large;
            break;
        }

        countup++;
    }
    cout << answer;

}

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

int main() {
	string s;
	cin >> s;
	bool ans = true;
	if (s.at(0) != 'A')ans = false;
	if (!('a' <= s.at(1) && s.at(1) <= 'z'))ans = false;
	if (!('a' <= s.at(s.length() - 1) && s.at(s.length() - 1) <= 'z'))ans = false;
	int big = 0;
	for (int i = 2; i <= s.length()-2; i++) {
		if ('A' <= s.at(i) && s.at(i) <= 'Z')big++;
	}
	if (big == 0 || big >= 2)ans = false;
	if (ans)cout << "AC" << endl;
	else cout << "WA" << endl;
}

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

int main(void){
  vector<int> tanku{5, 7, 5, 7, 7};
  while(1){
    int n; cin >> n;
    if(n == 0) break;
    vector<string> w(n);
    for(int i = 0; i < n; i++){
      cin >> w[i];
    }
    int idx = 0;
    int len = 0;
    while(idx < (int)w.size()){
      bool istanku = true;
      int ans = idx;
      for(int i = 0; i < (int)tanku.size(); i++){
        while(1){
          len += w[idx].size();
          idx++;
          if(len > tanku[i]){
            len = 0;
            istanku = false;
            break;
          }
          if(len == tanku[i]){
            len = 0;
            break;
          }
        }
        if(istanku == false) break;
      }

      if(istanku){
        cout << 1+ans << endl;
        break;
      }else{
        idx = ans+1;
      }
    }

  }
  return 0;
}



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

int main(){
  int N;
  int A=0,B=0;
  cin >> N;
  int a[N];
  for (int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a,a+N,greater<int>());
  for (int i=0;i<N;i++){
      if(i%2==0){
      A+=a[i];
    }
    else{
      B+=a[i];
    }

  }
  cout << A-B <<endl;
 }


Measured memory_bytes: 256
/*

*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <deque>
 
#define ll long long
#define cint const int
#define ld long double
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
 
using namespace std;
 
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, long long> pil;
typedef pair <int, string> pis;
typedef pair <int, char> pic;
typedef pair <long long, int> pli;
typedef pair <long long, string> pls;
typedef pair <long long, char> plc;
typedef pair <string, int> psi;
typedef pair <string, long long> psl;
typedef pair <string, char> psc;
typedef pair <char, int> pci;
typedef pair <char, long long> pcl;
typedef pair <char, string> pcs;

int n, m;

int main () {
	cin >> n >> m;
	int c = n / m;
  	if (n % m > 0) {
    	c++;
    }
  	cout << c;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
typedef unsigned long long int ull;

using namespace std;

int main(void){
  ull N,T;
  ull ans=0;
  cin >> N >> T;
  ull t[N];
  rep(i,N) cin >> t[i];
  ans=T*N;
  rep(i,N-1) if(t[i+1]-t[i]<T) ans-=T-(t[i+1]-t[i]);
  cout << ans << endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)
 
using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
using ulong=unsigned long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14
 
int main(){
    int n;
    cin >>n;
    vi d(n);
    rep(i,n) cin>>d[i];
 
    sort(beginend(d));
 
    int ans=1;
    int cnt=1;
    for(int i=1;i<n;++i){
        if(d[i]>d[i-1]) {
            cnt++;
        }else if(d[i]==d[i-1]) {
            continue;
        }else{
            ans=max(ans,cnt);
            cnt=1;
        }
    }
    ans=max(ans,cnt);
    out(ans);
}

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

typedef long long ll;
ll n, a[200005], num, tot;

ll iabs(ll a) {return a > 0 ? a : -a;}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], a[i] -= i;
    sort(a + 1, a + n + 1);
    num = a[(n + 1) >> 1];
    for (int i = 1; i <= n; i++) tot += iabs(a[i] - num);
    cout << tot << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static Scanner sc=new Scanner(System.in);
	static PrintWriter pr=new PrintWriter(System.out);
	public static void main(String[] args) {
		
		Main app=new Main();
		app.doing();
		
	}
	void doing(){
		int n= sc.nextInt();
		for (int i=0;i<n;i++) {
			final boolean[] judge= new boolean[3];
			int of = 0;
			int point = 0;
			while (of<3) {
				String str=sc.next();
				if ( "HIT".equals(str) ){
					if ( judge[2] ){
						judge[2]=false;
						point++;
					}
					judge[2]=judge[1];judge[1]=judge[0];judge[0]=true;
				} else if( "HOMERUN".equals(str)){
					point++;
					if ( judge[0] ) point++;if ( judge[1] ) point++;if ( judge[2] ) point++;
					Arrays.fill(judge, false);
				} else if( "OUT".equals(str))of++;
				
			}
			pr.println(point);
		}   
		pr.flush();
		
	}
}

Measured memory_bytes: 17224
#include <stdio.h>
#define N 100001
int t[N];
struct aur
{
	int x;
	int y;
};
struct aur next[N];
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&t[i]);
		scanf("%d %d",&next[i].x,&next[i].y);
	}
	for(i=1;i<=n;i++)
	{
		if(next[i].x+next[i].y>t[i])
		{
			printf("No\n");
			return 0;
		}
		if((next[i].x+next[i].y)%2!=t[i]%2)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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



int main() {
	ll r;
	cin >> r;
	cout << 3 * r*r;

	system("PAUSE");
}

Measured memory_bytes: 504
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  char a;
  cin >> a;
  if (isupper(a)) cout << 'A' << endl;
  else cout << 'a' << endl;
  return 0;
}


Measured memory_bytes: 3648
n,a,b = map(int,input().split())
X = list(map(int,input().split()))
ans = 0
for i in range(1,n):
    if (X[i]-X[i-1])*a <= b:
        ans += (X[i]-X[i-1])*a
    else:
        ans += b
print(ans)

Measured memory_bytes: 15020
import sys

S = input()
a , b , c = 0, 0 , 0

for s in S:
    if s == "a":
        a+=1
    elif s == "b":
        b+=1
    else:
        c+=1

m = min(a,b,c)

if a-m == 0 or a-m ==1:
    if b - m == 0 or b -m == 1:
        if c - m == 0 or c-m == 1:
            print("YES")
            sys.exit()

print("NO")

Measured memory_bytes: 3188
# coding: utf-8
N = int(input())
h = list(map(int,input().split()))
ans = 0
i = 0
while sum(h) != 0:
    if h[i] == 0:
        i+=1
        continue
    for _ in range(i,N):
        if h[_] != 0:
            h[_] = h[_] - 1
        else:
            break
    ans+=1
print(ans)

Measured memory_bytes: 3060
def main():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    k = int(input().rstrip('\n'))
    d = []
    for i in range(len(s)):
        for j in range(i + 1, min(i + 1 + k, len(s) + 1)):
            d.append(s[i:j])
    import collections
    d = sorted(collections.Counter(d).most_common())
    print(d[k-1][0])


if __name__ == '__main__':
    main()


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

#define MAX_N 100000
typedef long long int ll;

ll dp[MAX_N];

int main() {
  int n, h[MAX_N];

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

  dp[0] = 0;
  for(int i = 1; i < n; ++i) {
    if(i - 2 >= 0) {
      dp[i] = std::min(dp[i - 1] + std::abs(h[i] - h[i - 1]), dp[i - 2] + std::abs(h[i] - h[i - 2]));
    } else {
      dp[i] = dp[i - 1] + std::abs(h[i] - h[i - 1]);
    }
  }

  std::cout << dp[n - 1] << std::endl;
}


Measured memory_bytes: 1408
#include <stdio.h>
#define MAX 100000

int Depth(int);

struct node
{
  int p;
  int r;
  int l;
} typedef node;

node N[MAX];

int main()
{
    int i, j;
    int n, id, k, nid;

    scanf("%d", &n);
    
    for(i = 0; i < n; i++)
    {
        N[i].p = -1;
        N[i].r = -1;
        N[i].l = -1;
    }
    
    for(i = 0; i < n; i++)
    {
        scanf("%d %d", &id, &k);

        if(k > 0)
	    {
	        scanf("%d", &N[id].l);
	        N[N[id].l].p = id;
	        nid = N[id].l;
	    }
        for(j = 1; j < k; j++)
	    {
	        scanf("%d", &N[nid].r);
	        N[N[nid].r].p = id;
	        nid = N[nid].r;
	    }
    }
    
    for(i = 0; i < n; i++)
    {
        printf("node %d: ", i);

        printf("parent = %d, ", N[i].p);
 
        printf("depth = %d, ", Depth(i));

        if(N[i].p == -1) printf("root, ");
        else if(N[i].l == -1) printf("leaf, ");
        else printf("internal node, ");

        printf("[");
        if(N[i].l != -1)
	    {
	        printf("%d", N[i].l);
	        nid = N[i].l;
	    }
        while(N[nid].r != -1)
	    {
	    printf(", %d", N[nid].r);
	    nid = N[nid].r;
	    }
	    printf("]\n");
    }
    return 0;
}

int Depth(int id)
{
    int count = 0;

    while(N[id].p != -1)
    {
        count++;
        id = N[id].p;
    }
    return count;
}

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

int main()
{
	int a[3] = {};
	for (int i = 0; i<2; i++)
	{
		int x; cin>>x;
		a[x-1]++;
	}
	for (int i = 0; i<3; i++)
	{
		if (!a[i])
		{
			cout<<i+1;
			return 0;
		}
	}
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

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

      n=Integer.parseInt(sc.next());
      int[] l = new int[n];
      for(int i=0; i<n; i++){
        l[i]=Integer.parseInt(sc.next());
      }

      Arrays.sort(l);
      int lsum=0;
      for(int i=0; i<n-1; i++){
        lsum=lsum+l[i];
      }
      if(lsum>l[n-1]){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
                
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 21844