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

using namespace std;

// int jumps(int n, int N, int a[],int dp[]) {
//     int x,y;
//     x = y = INT_MAX;
//     if(n == N) return 0;
//     else if(dp[n] != 0) return dp[n];
//     else {
//         if(n+1 <= N) x = jumps(n+1,N,a,dp) + abs(a[n] - a[n+1]);
//         if(n+2 <= N) y = jumps(n+2,N,a,dp) + abs(a[n] - a[n+2]);
//         dp[n] = min(x,y);
//         return dp[n];
//     }
// }

int jumps(int N, int a[]) {
    int x,y;
    int dp[N+1] = {0};
    dp[1] = 0;
    x = y = INT_MAX;
    for(int i=2; i<=N; i++) {
        if(i-1 >=1) x = dp[i-1] + abs(a[i] - a[i-1]);
        if(i-2 >=1) y = dp[i-2] + abs(a[i] - a[i-2]);
        dp[i] = min(x,y);
    }
    return dp[N];
}

int main() {
    int N;
    cin>>N;
    int a[N+1]; 
    for(int i=1; i<=N; i++) cin>>a[i];
    cout<<jumps(N,a);
    return 0;
}

Measured memory_bytes: 4392
N, K = map(int, input().split())
*A, = map(int, input().split())

b = [i for i in A]
for c in range(K):
    buf = [0]*(N+1)
    for i, j in enumerate(b):
        buf[max(i-j, 0)] += 1
        buf[min(i+j+1, N)] -= 1
    for i in range(1, N+1):
        buf[i] += buf[i-1]
    b = [buf[i] for i in range(N)]
    if all([i==N for i in b]):
        break

print(*b)

Measured memory_bytes: 222580
#112D
N,M=map(int,input().split())
B=int((M**(1/2))//1)
A=[M//i for i in range(1,int((M**(1/2)+1)//1))]+list(range(1,B))
A.sort(reverse=True)
for i in A:
    flag=M-N*i
    if flag%i==0 and flag>=0:
        print(i)
        break

Measured memory_bytes: 6028
N = int(input())
S = [input() for _ in range(N)]

for i in range(N):
    S[i] = {c: S[i].count(c) for c in S[i]}
chars = {c for c in 'abcdefghijklmnopqrstuvwxyz'}
for s in S:
    chars &= set(s.keys())
ans = []
for c in chars:
    small = float('inf')
    for s in S:
        small = min(small, s[c])
    ans += [c] * small
ans.sort()
print(''.join(ans))


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

int main()
{
    char c;
    cin >> c;
    string s = "consonant";
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') s = "vowel";
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 764
//#pragma GCC optimize("O3")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

const int mod = 998244353;
const int inf = 9e18;
const int N = 2e5 + 5;

void solve(){
    int r;
    cin>>r;
    ld ans=2*pi*r;
    cout<<fixed<<setprecision(10)<<ans;
}

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

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define REVERSE(c) reverse((c).begin(), (c).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort((c).begin(),(c).end())
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
	LL N, H, W;
	cin >> N;
	cin >> H;
	cin >> W;

	cout << (N - H + 1) * (N - W + 1) << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define REP(i,k,n) for(int i=k;i<n;i++)

using namespace std;
int main(){
  int x,y,z;
  cin >> x >> y >> z;
  cout << (x-z)/(y+z) << endl;

  return 0;

}


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

int main(){
  string s;
  cin >> s;
  ll ans = 0;
  rep(bit, 1<<(s.size()-1)){
    ll tmp = 0;
    rep(i,s.size()-1){
      tmp *= 10;
      tmp += s[i]-'0';
      if (bit & (1<<i)) ans += tmp, tmp=0;
    }
    tmp *= 10;
    tmp += s.back() - '0';
    ans += tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
from collections import defaultdict as dd
import queue
import sys
input = sys.stdin.readline
N, M, K = map(int,input().split())
ab = [tuple(map(int,input().split())) for _ in range(M)]
cd = [tuple(map(int,input().split())) for _ in range(K)]
dic = dd(list)
for (a,b) in ab:
    dic[str(a)].append(b)
    dic[str(b)].append(a)
uf = [-1]*N
def BFS(ufid, dic, node):
    leng = -1
    q = queue.Queue()
    q.put(node)
    while not q.empty():
        now_node = q.get()
        if uf[now_node-1] > 0:
            continue
        leng += 1
        uf[now_node-1] = ufid
        target = [val for val in dic[str(now_node)] if uf[val-1]==-1]
        for tgt in target:
            q.put(tgt)
            uf[tgt-1] = 0
    return leng

len_ls = []
var = 1
for i in range(N):
    if uf[i] == -1:
        # 連結判定
        leng = BFS(var, dic, i+1)
        len_ls.append(leng)
        var += 1
for (a,b) in cd:
    if uf[a-1] == uf[b-1]:
        dic[str(a)].append(b)
        dic[str(b)].append(a)
res = [len_ls[uf[i]-1] - len(dic[str(i+1)]) for i in range(N)]
print(*res)


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


int main()
{


        long long n,m,a,b,c,d,e,f,g,p,q,r,fr,sc,tr,sz,tz,sz1,sz2,i,j,k,mx=-9,mn=999999999999; string str,ttr,ntr;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct,tct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr,mp1,mp2;

        //scanf("%lld",&n);

        int ara[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

        cin>>fr;

        cout<<ara[fr-1]<<endl;













    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n, k, s;
    cin >> n >> k >> s;
    if(s!=1000000000){
        rep(i, k){
            cout << s << " ";
        }
        rep(i, n-k){
            cout << 1000000000 << " ";
        }
    }else{
        rep(i, k){
            cout << s << " ";
        }
        rep(i, n-k){
            cout << 1 << " ";
        }
    }
    cout << endl;
    // printf("%d\n", N);
    return 0;
}

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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

const int INF = INT_MAX;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int n;

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    long double ans = 0;
    double ans2 = 0.0;
    cin >> n;
    REP(i, n) {
        long double x;
        std::string u;
        cin >> x;
        cin >> u;
        if(u == "JPY") ans += x;
        else ans += x * 380000.0;
    }
    cout << (double)ans + ans2 << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N, verdict[4] = {0}; // AC, WA, TLE, RE
  scanf("%d", &N);

  for(int i = 0; i < N; i++) {
    char str[5];
    scanf("%s", str);
    switch(str[0]) {
      case 'A':
        verdict[0]++;
        break;
      case 'W':
        verdict[1]++;
        break;
      case 'T':
        verdict[2]++;
        break;
      case 'R':
        verdict[3]++;
        break;
    }
  }

  printf("AC x %d\n", verdict[0]);
  printf("WA x %d\n", verdict[1]);
  printf("TLE x %d\n", verdict[2]);
  printf("RE x %d\n", verdict[3]);
  return 0;
}

Measured memory_bytes: 1724
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.annotation.tailrec
import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toInt

    implicit object TupleOrdering extends Ordering[(Int, Char, Array[Char])] {
      override def compare(x: (Int, Char, Array[Char]), y: (Int, Char, Array[Char])): Int = {
        @tailrec
        def inner(i: Int, x: Array[Char], y: Array[Char]): Int = {
          if (x(i) == y(i)) {
            inner(i + 1, x, y)
          } else {
            y(i) - x(i)
          }
        }

        inner(0, x._3, y._3)
      }
    }

    val queue = mutable.PriorityQueue.empty[(Int, Char, Array[Char])]

    queue.enqueue((n, 'a', Array.fill(n)(0)))

    while (queue.nonEmpty) {
      val (rest, ch, chars) = queue.dequeue()

      if (rest == 0) {
        out.println(chars.mkString(""))
      } else {
        var indices = chars.zipWithIndex.filter(_._1 == 0).map(_._2)
        chars(indices.head) = ch

        indices = indices.tail
        (0 until (1 << indices.length)).foreach { pattern =>
          val newChars = chars.clone()
          var count = 1
          indices.zipWithIndex.foreach {
            case (index, i) =>
              if ((pattern >> i & 1) == 0) {
                newChars(index) = ch
                count += 1
              }
          }
          queue.enqueue((rest - count, (ch + 1).toChar, newChars))
        }
      }
    }

    out.flush()
  }
}


Measured memory_bytes: 116672
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve (void)
{
  int H,W; cin>>H; cin>>W; 
  vector<vector<char> > vv (H+2,vector<char>(W+2,'#'));
  for (int h = 0; h < H; h++)
  {
    for (int w = 0; w < W; w++)
    {
      cin>>vv[h+1][w+1];
    }
    
  }
  for (int i = 0; i < H+2; i++)
  {
    for (int j = 0; j < W+2; j++)
    {
      cout<<vv[i][j];
    }
    cout<<endl;
    
  }
  
  
  
  
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
#define MAX 100
 
int main() {
  int n, i, j, minj, cnt = 0;
  int array[MAX], tmp, flag;
 
  scanf("%d\n", &n);
  i = 0;
  while ((scanf("%d", &array[i])) != EOF) {
    i++;
  }

  for (i = 0; i < n; i++) {
    minj = i;
    flag = 0;
    for (j = i; j < n; j++) {
      if (array[j] < array[minj]) {
	minj = j;
	flag = 1;
      }
    }
    if (flag) {
      tmp = array[i];
      array[i] = array[minj];
      array[minj] = tmp;
      cnt++;
    }
  }
 
  for (i = 0; i < n; i++) {
    if (i == n-1) {
      printf("%d\n", array[i]);
      break;
    }
    printf("%d ", array[i]);
  }
  printf("%d\n", cnt);
 
  return 0;
}

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

using namespace std;

const int N = 5005;
const int mod = 1e9 + 7;

int n, dp[N][N];
char s[N];

void add (int &x, int y) {
    x = (x + y) % mod;
}

int main(){
    scanf("%d", &n);
    scanf("%s", s);

    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (dp[i][j]) {
                add(dp[i + 1][j + 1], dp[i][j]);
                if (j) add(dp[i + 1][j - 1], 1LL * 2 * dp[i][j] % mod);
                else add(dp[i + 1][j], dp[i][j]);
            }
        }
    }

    printf("%d", dp[n][strlen(s)]);
    return 0;
}



Measured memory_bytes: 96384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  int k = sc.nextInt();
	  int q = sc.nextInt();
	  int []a = new int[n];
	  for(int i = 0;i < n;i++) {
		  a[i] = k - q;
	  }
	  for(int i = 0;i < q;i++) {
		  a[sc.nextInt() - 1]++;
	  }

	  for(int i = 0;i < n;i++) {
		  if(a[i] > 0) {
			  System.out.println("Yes");
		  }else {
			  System.out.println("No");
		  }
	  }
	}
}

Measured memory_bytes: 76304
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); 
    int X = sc.nextInt(); 
    int[] x = new int[N];  
    for (int i=0; i < N ;i++) {
      x[i] =  Math.abs(sc.nextInt()-X);
    }
    if(x.length==1){
      System.out.println(x[0]);
    }else{
      int tmp = x[0];
      for(int i = 0; i < N; i++){
        tmp = gcd(tmp,x[i]);
      }
      System.out.println(tmp);
    }
  }

  static int gcd(int a, int b){
    int max= Math.max(a,b);
    int min= Math.min(a,b);
    if(max%min==0){
      return min;
    }else{
      return gcd(max%min, min);
    }
  }  
}



Measured memory_bytes: 48376
def toi(a)
	b = []
	a.each do |n|
		b << n.to_i
	end
	b	
end


while true
a = toi(gets().split)
h = a[0]
w = a[1]

if h == 0 && w == 0
 break
end

for n in 1 .. h
	w.times do
		print("#")
	end
	puts "\n"
end
puts "\n"

end

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

const int mod = 1000000007;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll xx = 0) : x((xx % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main()
{
    mint m;
    ll n;
    cin >> m >> n;
    cout << m.pow(n) << endl;

    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) { if (a < b) { return b; } return a; }

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

int main() {
    ll k, s; cin >> k >> s;
    ll ans = 0; //ll x = 0, y = 0, z = 0;
    rep(h, k+1) {
        rep(i, k+1) {
            if (h+i > s || h+i+k < s) continue;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

const int maxn = 310;

int N, K, mod;
int dp[maxn][maxn], c[maxn][maxn], sum[maxn][maxn];

int main(int argc, char *argv[]) {
	scanf("%d%d%d", &N, &K, &mod);
	++N;
	for (int i = 0; i <= N; ++i) {
		c[i][0] = 1;
		for (int j = 1; j <= i; ++j) {
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
		}
	}
	for (int x = 0; x <= K; ++x) {
		dp[1][x] = 1;
	}
	for (int x = K; x >= 0; --x) {
		sum[1][x] = (1 + sum[1][x + 1]) % mod;
	}
	for (int n = 2; n <= N; ++n) {
		for (int x = 0; x <= K; ++x) {
			for (int i = 1; i < n; ++i) {
				dp[n][x] = ((long long) c[n - 2][i - 1] * sum[i][x + 1] % mod * dp[n - i][x] + dp[n][x]) % mod;
			}
//			debug("dp[%d][%d] = %d\n", n, x, dp[n][x]);
		}
		for (int x = K; x >= 0; --x) {
			sum[n][x] = (dp[n][x] + sum[n][x + 1]) % mod;
		}
	}
	printf("%d\n", (dp[N][0] + mod) % mod);
	return 0;
}



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


int main(){
    int n;
    int sum=0;
    int ma=0;
    cin >> n;
    rep(i,n){
        int l;
        cin >> l;
        ma=max(l,ma);
        sum+=l;
    }
    sum-=ma;
    if(ma<sum) cout << "Yes" << endl;
    else  cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import math

x = int(input())
x = abs(x)

# sum = sec(sec+1)/2
a = math.ceil((2 * x) ** (0.5))
s = a * (a+1) // 2

while s >= x:
    a -= 1
    s = a * (a+1) // 2

print(a+1)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

int main() {
    std::string S;
    std::cin >> S;
    
    S.erase(std::unique(S.begin(), S.end()), S.end());
    std::sort(S.begin(), S.end());
    if (S=="abc")
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

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

using UnWeightedGraph = vector<vector<int>>;
struct LowLink {
    const UnWeightedGraph &g;
    vector<int> aps;                // articulation points
    vector<pair<int, int>> brs;     // brides
    vector<int> seen, ord, low;
    LowLink(const UnWeightedGraph &g) : g(g) { }
    int dfs(int u, int p = -1, int time = 0) {
        seen[u] = true;
        ord[u] = low[u] = time++;
        bool exists = false;
        int cnt_ch = 0;
        for (int v: g[u]) {
            if (!seen[v]) {
                ++cnt_ch;
                time = dfs(v, u, time);
                low[u] = min(low[u], low[v]);   // forward edge
                if (ord[u] < low[v]) brs.emplace_back(u, v);
                if (ord[u] <= low[v]) exists = true;
            } else if (v != p) {
                low[u] = min(low[u], ord[v]);   // back edge
            }
        }
        if ((p == -1 && cnt_ch > 1) || (p != -1 && exists)) aps.emplace_back(u);
        return time;
    }
    void build() {
        int N = g.size();
        seen.assign(N, 0); ord.resize(N); low.resize(N);
        aps.clear(); brs.clear();
        for (int v = 0; v < N; ++v) if (!seen[v]) dfs(v);
        for (auto &br: brs) if (br.first > br.second) swap(br.first, br.second);
        sort(brs.begin(), brs.end());
        sort(aps.begin(), aps.end());
    }
};
struct TwoEdgeConnectedComponents : LowLink {
    using LL = LowLink;
    vector<int> comp;
    TwoEdgeConnectedComponents(const UnWeightedGraph &g) : LL(g) { }
    int operator[](int k) { return comp[k]; }
    void dfs(int u, int p, int &k) {
        if (~p && this->ord[p] >= this->low[u]) comp[u] = comp[p];
        else comp[u] = k++;
        for (int v: this->g[u]) if (comp[v] == -1) dfs(v, u, k);
    }
    UnWeightedGraph build() {
        LL::build();
        comp.assign(this->g.size(), -1);
        int k = 0;
        for (int i = 0; i < comp.size(); ++i) if (comp[i] == -1) dfs(i, -1, k);
        UnWeightedGraph t_comp(k);
        for (auto &e: this->brs) {
            int x = comp[e.first], y = comp[e.second];
            t_comp[x].emplace_back(y);
            t_comp[y].emplace_back(x);
        }
        return t_comp;
    }
};

UnWeightedGraph tree;
vector<int> size;
vector<vector<int>> dp;
void dfs(int u, int p) {
    dp[0][u] = 0;
    dp[1][u] = size[u];
    for (int v: tree[u]) if (v != p) {
        dfs(v, u);
        dp[0][u] += max(dp[0][v], dp[1][v]);
        dp[1][u] += dp[0][v];
    }
}
int main() {
    int N, M; cin >> N >> M;
    UnWeightedGraph g(N);
    for (int i = 0; i < M; i++) {
        int s, t; cin >> s >> t;
        g[s].emplace_back(t);
        g[t].emplace_back(s);
    }
    TwoEdgeConnectedComponents bcc(g);
    tree = bcc.build();
    int V = tree.size();
    size.assign(V, 0);
    for (int i = 0; i < N; i++) size[bcc[i]]++;
    int ans = 0;
    dp.assign(2, vector<int>(V, -1));
    for (int i = 0; i < V; i++) if (dp[0][i] == -1) {   // 森
        dfs(i, -1);
        ans += max(dp[0][i], dp[1][i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 17868
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

class Elem {
	int x;
	Elem prev, next;
	Elem(int x, Elem prev, Elem next) {
		this.x = x;
		this.prev = prev;
		this.next = next;
	}
}
class Dll {
	Elem head = null, tail = null;
	void insert(int x) {
		Elem next = head;
		head = new Elem(x, null, next);
		if (next != null) next.prev = head;
		if (tail == null) tail = head;
	}
	void delete(int x) {
		Elem e = head;
		while (e != null) {
			if (e.x == x) {
				if (e.prev == null && e.next == null) {
					tail = head = null;
					break;
				}
				if (e.prev != null) {
					e.prev.next = e.next;
				} else {
					e.next.prev = null;
					this.head = e.next;
				}
				if (e.next != null) {
					e.next.prev = e.prev;
				} else {
					e.prev.next = null;
					this.tail = e.prev;
				}
				break;
			} else {
				e = e.next;
			}
		}
	}

	void deleteFirst() {
		if (head != null) {
			if (head == tail) head = tail = null;
			else {
				head = head.next;
				head.prev = null;
			}
		}
	}

	void deleteLast() {
		if (tail != null) {
			if (head == tail) head = tail = null;
			else {
				tail = tail.prev;
				tail.next = null;
			}
		}
	}

	void print() {
		if (head != null) {
			System.out.print(head.x);
			Elem e = head.next;
			while (e != null) {
				System.out.print(" " + e.x);
				e = e.next;
			}
			//System.out.println("\n tail: " + tail.x);
		}
	}
	void printRev() {
		if (tail != null) {
			System.out.print(tail.x);
			Elem e = tail.prev;
			while (e != null) {
				System.out.print(" " + e.x);
				e = e.prev;
			}
		} else {
			System.out.println("EMPTY");
		}
	}
}

public class Main {
	final boolean usesc = false;

	void run() {
		int n = 0;
		Scanner sc = null;
		BufferedReader br = null;
		if (usesc) {
			sc = new Scanner(System.in);
			n = sc.nextInt();
		} else {
			br = new BufferedReader(new InputStreamReader(System.in));
			try {
				n = Integer.parseInt(br.readLine());
			} catch (Exception e) {
				System.exit(-1);
			}
		}
		Dll dll = new Dll();
		for (int i = 0; i < n; i++) {
			String line = null;
			String cmd = null;
			int arg = 0;
			if (usesc) {
				cmd = sc.next();
			} else {
				try {
					line = br.readLine();
				} catch (Exception e) {
					System.exit(-1);
				}
				String[] s = line.split(" ");
				cmd = s[0];

				arg = s.length == 2 ? Integer.parseInt(s[1]) : -1;
			}

			if (cmd.equals("insert")) {
				if (!usesc) {
					dll.insert(arg);
				} else {
					dll.insert(sc.nextInt());
				}
			}
			else if (cmd.equals("delete")) {
				if (!usesc) {
					dll.delete(arg);
				} else {
					dll.delete(sc.nextInt());
				}
			}
			else if (cmd.equals("deleteFirst")) {
				dll.deleteFirst();
			}
			else if (cmd.equals("deleteLast")) {
				dll.deleteLast();
			}
			else System.out.println("ERROR");
		}
		dll.print();
		System.out.println();
	}

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



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

typedef long long ll;

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

    char c = s[0];
    ll ans = 0;

    for(ll i = 1; i < s.size() ; i++){
        if(s[i] != c){
            ans++;
            c = s[i];
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 512
import std.stdio;
import std.array;
import std.conv;

void main(){
	string[] str;
	int n, min;
	int[1000] count;
	while (readf("%d\n", &n) && n) {
		int[] s;
		str = split(readln());
		count[] = 0;
		foreach (i; str) {
			s ~= to!int(i);
			count[s.back]++;
		}
		min = 0;
		for (min = 0; true; min++) {
			int[] c;
			for (int i = 0; i < n; i++) {
				c ~= count[s[i]];
			}
			if (s == c) {
				writeln(min);
				write(s.front); s.popFront();
				foreach (i; s) {
					write(" ", i);
				}
				writeln();
				break;
			}else {
				s = c;
				count[] = 0;
				foreach (i; s) {
					count[i]++;
				}
			}
		}
	}
}

Measured memory_bytes: 1012
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
   int N,M,L;
   cin >> N >> M >> L;
   vector<int> edge[N];
   int dist[N][N];
   for(int i=0;i<N;i++)for(int j=0;j<N;j++) dist[i][j]= INT_MAX/2;
   for(int i=0;i<M;i++){
      int a,b,c;
      cin >> a >> b >> c;
      a--;b--;
      dist[a][b]= c;
      dist[b][a]= c;
   }
   for(int k = 0 ; k <N; k++){
      for(int i = 0; i < N ; i++){
         for(int j = 0 ; j <N; j++){
            dist[i][j]=min(dist[i][j], dist[i][k]+dist[k][j]);
         }
      }
   }
   int dist2[N][N];
   for(int i=0;i<N;i++)for(int j=0;j<N;j++) dist2[i][j]= INT_MAX/2;
   
   for(int i = 0 ; i < N; i++){
      for(int j = i+1; j < N; j++){
         //cout << i << " " << j << ":" << dist[i][j] << endl;
         if(dist[i][j]<=L){
            //cout << i<< ":" << j << endl;
            dist2[i][j]=1;
            dist2[j][i]=1;
         }
      }
   }
   for(int k = 0 ; k <N; k++){
      for(int i = 0; i < N ; i++){
         for(int j = 0 ; j <N; j++){
            dist2[i][j]=min(dist2[i][j], dist2[i][k]+dist2[k][j]);
         }
      }
   }
   int Q;
   cin >> Q;
   for(int q = 0; q <Q; q++){
      int s,t;
      cin >> s >> t;
      s--;t--;
      int ans = -1;
      if(dist2[s][t]!=INT_MAX/2) ans = dist2[s][t]-1;
      cout << ans << endl; 
   }
   return 0;
}


Measured memory_bytes: 4316
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;

void solve(){
	lint n; cin >> n;
	lint dap = n - 1;
	for(int i=2; i<1010101 && i<n; i++){
		if(n % i == 0) dap = min(dap, i + n / i - 2);
	}
	cout << dap << endl;
}

int main(){	
	/*
	freopen("input.txt", "rb", stdin);
	freopen("output.txt", "wb", stdout);

	int tc; cin >> tc;
	*/ int tc = 1;
	for(int i=1; i<=tc; i++){
		solve();
	}
}





Measured memory_bytes: 256
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
dp = [0 for _ in range(n+10)]
dp[0] = 1
for x in a:
    dp[x] = -1
mod = 10**9 + 7
for i in range(n):
    if dp[i] < 0:
        continue
    if dp[i+1] >= 0:
        dp[i+1] += dp[i]
        dp[i+1] %= mod
    if dp[i+2] >= 0:
        dp[i+2] += dp[i]
        dp[i+2] %= mod
print(dp[n])

Measured memory_bytes: 7856
#include<iostream>
using namespace std;
int main()
{
    char str[50],strr[50];
    cin>>str>>strr;
    int n,m;
    cin>>n>>m;
    char u[100];
    cin>>u;
    if(u[0]==str[0])
    {
        n--;
    }
    else
    {
        m--;
    }

    cout<<n<<" "<<m<<endl;

}


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

int main() {
	string s;
	cin >> s;
	int a = 0;
	if(s.at(0) != 'C'){
		a++;
	}
	if(s.at(1) != 'O'){
		a++;
	}
	if(s.at(2) != 'D'){
		a++;
	}
	if(s.at(3) != 'E'){
		a++;
	}
	if(s.at(4) != 'F'){
		a++;
	}
	if(s.at(5) != 'E'){
		a++;
	}
	if(s.at(6) != 'S'){
		a++;
	}
	if(s.at(7) != 'T'){
		a++;
	}
	if(s.at(8) != 'I'){
		a++;
	}
	if(s.at(9) != 'V'){
		a++;
	}
	if(s.at(10) != 'A'){
		a++;
	}
	if(s.at(11) != 'L'){
		a++;
	}
	if(s.at(12) != '2'){
		a++;
	}
	if(s.at(13) != '0'){
		a++;
	}
	if(s.at(14) != '1'){
		a++;
	}
	if(s.at(15) != '6'){
		a++;
	}
	cout << a << endl;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



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

    int ans = 0;
    int now = 0;

    for(int i=0;i<n;i++){
        if(s[i]=='I'){
            now++;
        }else{
            now--;
        }
        ans = max(ans,now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var  ab = ReadLine().Split().Select(int.Parse).ToArray();
        var a = ab[0];
        var b = ab[1];
        WriteLine(Math.Max(Math.Max(a+b,a-b),a*b));
    }

}

Measured memory_bytes: 13268
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i, MOD))) % MOD
    dp[temp] += 1

for item in dp:
    if item > 1:
        ans += item*(item-1)//2

print(ans)



Measured memory_bytes: 68508
N, Q = map(int, input().split())
S = input()
qn = [list(map(int, input().split())) for _ in range(Q)]
S = "0" + S
cnt = [0 for _ in range(N+1)]
# cnt.append(0)
for i in range(1, N+1):
    if (S[i-1:i+1] == "AC"):
        cnt[i] = cnt[i-1] + 1
    else:
        cnt[i] = cnt[i-1]
for q in qn:
    l, r = q
#     print(l, cnt[l-2], r, cnt[r-1])
    print(cnt[r] - cnt[l])


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

int main() {
  int H, W;
  cin >> H >> W;

  vector<string> bmMap(H);
  for (int i = 0; i < H; ++i) {
    cin >> bmMap.at(i);
  }

  vector<int> range = {-1, 0, 1};

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (bmMap.at(i).at(j) == '#') {
        cout << '#';
        continue;
      }

      int bm = 0;
      // 周りのボムをカウント
      for (const auto& hd : range) {
        // 範囲外チェック
        if (i + hd < 0 || i + hd >= H) continue;
        for (const auto& wd : range) {
          // 範囲外チェック
          if (j + wd < 0 || j + wd >= W) continue;

          if (bmMap.at(i + hd).at(j + wd) == '#') {
            bm += 1;
          }
        }
      }

      cout << bm;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long C = long.Parse(str[2]);
		string ans = "No";
		if(A==B && B!=C){
			ans = "Yes";
		} else if(B==C && C!=A){
			ans = "Yes";
		} else if(C==A && A!=B){
			ans = "Yes";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
typedef vector<iii> viii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000

void solve() {
    char c;
    cin >> c;
    if ((c - 'A') <= 25) {
        cout << "A\n";
    }
    else {
        cout << "a\n";
    }
}

void querySolve() {
    int n;
    cin >> n;
    while (n--) {
        solve();
    }
}

int main() {
    //querySolve();
    solve();
    
}


Measured memory_bytes: 3624
import itertools
#import math

n = int(input())
#n = 2
#p = tuple(map(int,input().split(" ")))
#q = tuple(map(int,input().split(" ")))

p = input()
q = input()
#print(n)
#print(p)
i = 0
#a = 0 
#b = 0

for x in itertools.permutations(range(1,n+1), n):
	#print(x)
	x = " ".join(map(str,x))
	#print(x)
	i += 1
	if x == p:
		a = i
		#print(i)
	if x == q:
		b = i
		#print(i)

print(abs(a-b))
     

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define X first;
#define Y second;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5 + 10;
const int maxK = 1e4+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1e9+7;

ll a[maxN];
ll f[maxN];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	f[1] = 1000;
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<i;j++)
		{
			f[i] = max(f[i-1],f[j]/a[j] * a[i] + f[j]%a[j]);
		}
	}
	cout<<f[n]<<endl;
	return 0;
}

Measured memory_bytes: 3616
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  if (n == 3) {
    println("2 5 63")
    return
  }

  val xs = mutableListOf<Int>()
  var remainingN = n
  for (k in 0 until 2500) {
    if (remainingN >= 2) {
      xs.add(12 * k + 2)
      xs.add(12 * k + 4)
      remainingN -= 2
    }
    if (remainingN >= 2) {
      xs.add(12 * k + 3)
      xs.add(12 * k + 9)
      remainingN -= 2
    }
    if (remainingN >= 2) {
      xs.add(12 * k + 8)
      xs.add(12 * k + 10)
      remainingN -= 2
    }
  }
  for (k in 0 until 2500) {
    if (remainingN >= 1) {
      xs.add(12 * k + 6)
      remainingN -= 1
    }
    if (remainingN >= 1) {
      xs.add(12 * k + 12)
      remainingN -= 1
    }
  }
  println(xs.joinToString(" "))
}


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

int main() {

    ll N, K;
    cin >> N >> K;
    ll R, S, P;
    cin >> R >> S >> P;
    string T;
    cin >> T;

    ll sum = 0;
    // string S = "";
    string res = "";
    for (ll i = 0; i < N; i++) {
        if (T[i] == 'r') {
            if (i >= K && T[i-K] == 'r' && res[i-K] == 'w') {
                res += 'd';
            }
            else {
                res += 'w';
                sum += P;
            }
        } else if (T[i] == 's') {
            if (i >= K && T[i-K] == 's' && res[i-K] == 'w') {
                res += 'd';
            }
            else {
                res += 'w';
                sum += R;
            }
        } else {
            if (i >= K && T[i-K] == 'p' && res[i-K] == 'w') {
                res += 'd';
            }
            else {
                res += 'w';
                sum += S;
            }
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


main(){
  int a,b;
  cin>>a>>b;

  cout<<(3*a+b)/2<<endl;
}


Measured memory_bytes: 256
// Aizu Vol-3 0316: Fishing Competition
// 2017.8.25

#include <stdio.h>

int main()
{
	int h1, h2, k1, k2, a, b, c, d;
	int p1, p2;

	scanf("%d%d%d%d%d%d%d%d", &h1, &h2, &k1, &k2, &a, &b, &c, &d);
	p1 = h1*a + h2*b + (h1/10)*c + (h2/20)*d;
	p2 = k1*a + k2*b + (k1/10)*c + (k2/20)*d;
	if (p1 == p2) puts("even");
	else puts(p1 > p2 ? "hiroshi" : "kenjiro");
	return 0;
}

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

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

    int t[N],x[N],y[N];
    int res=0;

    for(int i=0;i<N;i++){
        cin >> t[i] >> x[i] >> y[i];
        if(i == 0){
            int times = t[i] - 0;
            int dist = abs(x[i] - 0) + abs(y[i] - 0);
//            cout << i << "<" << times << "<" << dist << endl;
            if(times >= dist && (times%2)==(dist%2)){
                res++;
            }
        }

        else if(i != 0){
            int times = t[i] - t[i-1];
            int dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
            if(times >= dist && (times%2)==(dist%2)){
                res++;
            }
        }
    }
    if(res == N){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main() {
    //初期化
    int a[5][205], dp[5][105];
    memset(dp, 0, sizeof(dp));
    memset(a, 0, sizeof(a));

    //入力
    int n;
    cin >> n;
    for(int i=1; i<=2; i++) for(int j=1; j<=n; j++) cin >> a[i][j];

    for(int i=1; i<=2; i++) {
        for(int j=1; j<=n; j++) {
            dp[i][j] = max(dp[i][j-1], dp[i-1][j]) + a[i][j];
        }
    }
    cout << dp[2][n] << endl;
}

Measured memory_bytes: 3600
candidate = int(input())
ave_temp, ide_temp = map(float, input().split(' '))
ls_candidate = [abs((ave_temp - (float(x) * 0.006) - ide_temp))  for x in input().split(' ')]

for x, i in enumerate(ls_candidate):
    if ls_candidate[x] == min(ls_candidate):
        print(x + 1)
        break

Measured memory_bytes: 3060
x = int(input())
if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
elif x < 2000:
    print(1)


Measured memory_bytes: 61928
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<tuple>
#include<map>
#define DB double
#define LL long long
#define PP std::pair<DB,DB>
#define MPP std::make_pair
#define TT std::tuple<int,int,int>
#define INF (100000000000000000)
int N;
std::vector<LL> A;
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		LL tmp;
		std::cin >> tmp;
		A.push_back(tmp);
	}
	std::sort(A.begin(), A.end());
	LL sum = 0;
	int t = 0;
	for (int i = 0; i < N - 1; i++) {
		sum += A[i];
		if (2 * sum < A[i + 1])t = i + 1;
	}
	std::cout <<  N-t<< std::endl;
	return 0;
}

Measured memory_bytes: 1400
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();
		int W = sc.nextInt();

		long[][] c = new long[10][10];
		long INF = 10000000;
		WF wf = new WF(c, INF);
		for(int i=0; i<10; i++) {
			for(int j=0; j<10; j++) {
				c[i][j] = sc.nextLong();
			}
		}
		long[][] min_c = wf.getAllDis();

		long min_maryoku = 0;
		int[][] A = new int[H][W];
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				A[i][j] = sc.nextInt();

				if(A[i][j] != -1 && A[i][j] != 1) {
					min_maryoku += min_c[A[i][j]][1];
				}
			}
		}

		System.out.println(min_maryoku);

	}

	//ワーシャルフロイド法
	public static class WF{
		long[][] d;
		long INF;

		public WF(long[][] d, long INF) {
			this.d = d;
			this.INF = INF;

			//初期化
			for(int i=0; i<d.length; i++) {
				Arrays.fill(d[i], INF);
			}

			//自分自身との距離を0に設定
			for(int i=0; i<d.length; i++) {
				d[i][i] = 0;
			}
		}

		//全頂点間の最短距離(重みに負の値あり)(ワーシャルフロイド法)(O(V^3))
		public long[][] getAllDis(){

			for(int k=0; k<d.length; k++) {
				for(int i=0; i<d.length; i++) {
					for(int j=0; j<d.length; j++) {
						if(d[i][k] != INF && d[k][j] != INF) {
							d[i][j] = Math.min(d[i][j], d[i][k]+d[k][j]);
						}
					}
				}
			}

			return d;
		}

		//負の閉路検出(O(V))
		public boolean isNegativeCycle() {
			for(int i=0; i<d.length; i++) {
				if(d[i][i] < 0) {
					return true;
				}
			}

			return false;
		}
	}
}


Measured memory_bytes: 47696
# CODE FESTIVAL 2017 予選 A: B – fLIP
N, M, K = [int(s) for s in input().split()]

canDo = 'No'

for n in range(0, N + 1):
    for m in range(0, M + 1):
        if n * (M - m) + m * (N - n) == K:
            canDo = 'Yes'
            break

print(canDo)    

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

using namespace std;

int main()
{
  uint64_t N;
  cin >> N;
  
  vector<uint64_t> A(N);
  for (uint64_t n = 0; n < N; ++n) {
    cin >> A[n];
  }
  
  vector<int64_t> x(N, 0);
  
  vector<int64_t> a1(N, 0);
  for (uint64_t n = 0; n < N; ++n) {
    a1[n] = (n % 2 == 0) ? 1 : -1;
  }
  
  for (uint64_t n = 0; n < N; ++n) {
    x[0] += a1[n] * A[n];
  }
  
  for (uint64_t n = 1; n < N; ++n) {
    x[n] = (2 * A[n - 1]) - x[n - 1];
  }
  
  for (uint64_t n = 0; n < N; ++n) {
    cout << x[n];
    if (n + 1 < N) { cout << ' '; }
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<vector>
using namespace std;
const int MAX = 100005;

int main() {
	int N;
	cin >> N;
	vector<int> A(MAX);
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		A[x]++;
	}

	int Q;
	cin >> Q;
	long long ans = 0;
	for (int i = 0; i < MAX; i++) {
		ans += (long long)i * A[i];
	}

	for (int i = 0; i < Q; i++) {
		int B, C;
		cin >> B >> C;
		ans += ((long long)C - B) * A[B];
		A[C] += A[B];
		A[B] = 0;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3796
//
//AtCoder Beginner Contest 121
//C
//https://atcoder.jp/contests/abc121/tasks/abc121_c
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<pair<ll,ll>> ab(n);
    REP(i, n) cin >> ab[i].first >> ab[i].second;

    sort(ALL(ab));
    ll ans=0;
    REP(i,n){
        if (m>ab[i].second) {
            ans += ab[i].first*ab[i].second;
            m -= ab[i].second;
        }else{
            ans += ab[i].first * m;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4852
n, k = map(int, raw_input().strip().split())
diss = map(int, raw_input().strip().split())

like = [1] * 10
for d in diss: like[d] = 0

ok = 1
amt = n
for c in str(amt):
    if not like[int(c)]:
        ok = 0
        break

while not ok:
    amt += 1

    ok = 1
    for c in str(amt):
        if not like[int(c)]:
            ok = 0
            break

print amt

Measured memory_bytes: 32156
#include <stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a < 9 && b < 9 && (a + b) < 17)
	{
		printf("Yay!\n");
	}
	else
		printf(":(\n");
	
return 0;
}

Measured memory_bytes: 128