akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]){
		puts("YES");
	}else puts("NO");
 	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;



/******************************************************************************************/


const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

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

	
	int n;
	cin >> n;
	string s;
	cin >> s;
	s = " " + s;

	vector<int> cnt(n + 10, 0);


	for (int i = 1; i <= n; i++)
	{
		if (s[i] == 'E') {
			cnt[i] = 1;
		}
	}

	for (int i = 0; i < n; i++)
	{
		cnt[i + 1] += cnt[i];
	}



	int mini = INT32_MAX;
	for (int i = 1; i <= n; i++)
	{
		
		if (s[i] == 'E') {

			int right = (cnt[n] - cnt[i]);
			int left = (i - 1 - 0) - (cnt[i - 1] - cnt[0]);
			mini = min(mini, right + left);
			//cout << "left = " << left << " right= " << right << endl;
		}
		else
		{
			int right = (cnt[n] - cnt[i]);
			int left = (cnt[i - 1] - cnt[0]);

			mini = min(mini, right + left);

			//cout << "left = " << left << " right= " << right << endl;
		}

	}
	cout << mini << endl;

}


Measured memory_bytes: 1904
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] a = new int[N+1];
    int[] b = new int[N+1];
    int[] c = new int[N+1];

    for (int i = 1; i < N+1; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
      c[i] = sc.nextInt();
    }

    sc.close();

    // dp[i][0]:a dp[i][1]:b dp[i][2]:c
    int[][] dp = new int[N+1][3];

    for (int i = 1; i < N+1; i++) {
      dp[i][0] = Math.max(dp[i-1][1], dp[i-1][2]) + a[i];
      dp[i][1] = Math.max(dp[i-1][0], dp[i-1][2]) + b[i];
      dp[i][2] = Math.max(dp[i-1][0], dp[i-1][1]) + c[i];
    }

    System.out.println(Math.max(dp[N][0], Math.max(dp[N][1], dp[N][2])));

  }

}

Measured memory_bytes: 95636
import math

def plot(x,y):
    print(f'{x:.8f} {y:.8f}')
    
def Koch(n,x1,y1,x2,y2):
    if n==0:
        plot(x1,y1)
        return
    sx=(2*x1+x2)/3
    sy=(2*y1+y2)/3
    tx=(x1+2*x2)/3
    ty=(y1+2*y2)/3
    ux=(tx-sx)*(1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy=(tx-sx)*(math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    Koch(n-1,x1,y1,sx,sy)
    Koch(n-1,sx,sy,ux,uy)
    Koch(n-1,ux,uy,tx,ty)
    Koch(n-1,tx,ty,x2,y2)

n=int(input())
Koch(n, 0,0, 100,0)
plot(100,0)


Measured memory_bytes: 5752
X,Y,A,B,C = map(int,input().split())


RED = list(map(int,input().split()))
GREEN = list(map(int,input().split()))
NON = list(map(int,input().split()))

ALL = []
for i in range(A):
    ALL.append([RED[i],'red'])
for i in range(B):
    ALL.append([GREEN[i],'green'])    
for i in range(C):
    ALL.append([NON[i],'non'])  
    
ALL.sort()
ALL = ALL[::-1]

red = 0
green = 0
non = 0
now = 0
ans = 0

while 1:
    tmpS,tmpcolor = ALL[now]
    
    if tmpcolor == 'red':
        if red<X and red+green+non<X+Y:
            ans += tmpS
            red += 1
    elif tmpcolor == 'green':
        if green<Y and red+green+non<X+Y:
            ans += tmpS
            green += 1
    elif tmpcolor == 'non':
        if red+green+non<X+Y:
            ans += tmpS
            non += 1
    if red+green+non==X+Y:
        break
    now += 1
    
print(ans)

Measured memory_bytes: 128620
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iostream>
#include<queue>
#include<map>
#include<ctime>
using namespace std;
int m,d,ans;
int main(){
	scanf ("%d%d",&m,&d);
	for (int i = 1;i <= m;i ++){
		for (int j = 2;j <= 9;j ++){
			for (int k = 2;k <= 9;k ++){
				if (10 * j + k > d)
					continue;
				else if (j * k == i)
					ans ++;
			}
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
# ABC068c
import collections
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n, m = map(int, input().split())
INF = 10**12


class Edge:  # 通常の辺
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost


class Dijkstra:  # ダイクストラ法 O(E * logV)
    def __init__(self, n):
        self.n = n
        self.dist = [INF for _ in range(n)]
        self.edges = [list() for _ in range(n)]
        self.q = collections.deque()

    def calcShortest(self, start):
        self.q.append((start, 0))
        while(len(self.q) != 0):
            v, cost = self.q.popleft()
            if cost > 2:
                continue
            if self.dist[v] <= cost:
                continue
            self.dist[v] = cost
            for edge in self.edges[v]:
                self.q.append((edge.to, cost+edge.cost))

    def addEdge(self, st, gl, cost):
        self.edges[st].append(Edge(gl, cost))


v = Dijkstra(n)
for _ in range(m):
    a, b = map(int, input().split())
    v.addEdge(a-1, b-1, 1)
    v.addEdge(b-1, a-1, 1)

v.calcShortest(0)
if v.dist[n-1] <= 2:
    print('POSSIBLE')
    exit(0)
print('IMPOSSIBLE')


Measured memory_bytes: 118060
'use strict';
const main = input => {
  const n = parseInt(input[0]);
  const t = parseInt(input[1].split(' ')[0]), a = parseInt(input[1].split(' ')[1]);
  const h = input[2].split(' ').map(val => parseInt(val));
  // console.log(n, t, a, h);
  let min = 10000000, ans = 0;
  h.map((val, id) => {
    if(min > Math.abs(a-(t-val*0.006))) {
      min = Math.abs(a-(t-val*0.006));
      ans = id+1;
    }
  })
  console.log(ans);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7500
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = Integer.parseInt(sc.next());
		int X = Integer.parseInt(sc.next());
		sc.close();

		double res = (double)T/X;

		System.out.println(res);
	}

}


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

int main() {
	int N; scanf("%d", &N);
	map<int, int> cnt;
	for (int i = 0; i < N; i++) {
		int a; scanf("%d", &a);
		cnt[a]++;
	}

	if (N == cnt[0]) {
		puts("Yes");
		return 0;
	}

	vector<int> vals;
	for (const auto& p : cnt) {
		for (int i = 0; i < p.second / (N / 3); i++) {
			vals.push_back(p.first);
		}
	}

	if (N % 3 == 0 && vals.size() == 3 && 0 == (vals[0] ^ vals[1] ^ vals[2])) {
		puts("Yes");
	} else {
		puts("No");
	}

	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    double result = 0;
    for (int i=0; i<n; i++) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") {
            result += x;
        } else {
            result += x * 380000.0;
        }
    }
    cout << result << endl;
}

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

int main(void){
  string n;cin >> n;
  rep(i,3){
    if(n[i] == '1')cout << 9;
    else cout << 1;
  }
  cout << endl;
  return 0;
}


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

signed main(){
  string s;
  cin>>s;
  int n=s.size(),t=0;
  r(i,n)if(s[i]=='p')t++;
  cout<<n/2-t<<endl;
}


Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
import bisect
a.sort()
c.sort()
cl=len(c)
cnt=0
for i in b:
    x=bisect.bisect_left(a,i)
    y=bisect.bisect_right(c,i)
    cnt+=x*(cl-y)
print(cnt)
    


Measured memory_bytes: 23204
#include <iostream>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;
#define size_t long long

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

	map<pair<size_t, size_t>, size_t> foxes;
	auto count = [&foxes](size_t x, size_t y) -> size_t {
		auto it = foxes.find(make_pair(x, y));
		if (it == foxes.end()) {
			return 0;
		}
		else {
			return it->second;
		}
	};

	for (int i = 0; i < N; i++) {
		size_t x, y, f;
		cin >> x >> y >> f;
		foxes[make_pair(x, y)] = f;
	}

	size_t max_foxes = 0;
	for (auto v : foxes) {
		auto x = v.first.first;
		auto y = v.first.second;
		auto num = v.second +
			count(x + 1, y) +
			count(x, y + 1) +
			count(x + 1, y + 1);
		max_foxes = max(max_foxes, num);
		num = v.second +
			count(x - 1, y) +
			count(x, y + 1) +
			count(x - 1, y + 1);
		max_foxes = max(max_foxes, num);
	}
	cout << max_foxes << " / 1" << endl;
}

Measured memory_bytes: 9320
s, t, d = gets.split.map(&:to_i)
ws = gets.split.map(&:to_i)
min = ws.inject([0]) {|a, w| a + [a[-1] + w]}.min
week = ws.inject(:+)

if min >= 0
  puts -1
elsif week >= 0
  if s + min > t
    puts -1
  else
    (0..d-1).each do |i|
      s += ws[i]
      if s <= t
        puts i + 1
        break
      end
    end
  end
else
  k = 0
  until s + min <= t
    k += d
    s += week
  end
  (0..d-1).each do |i|
    s += ws[i]
    if s <= t
      puts k + i + 1
      break
    end
  end
end



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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int n,m,k;
    cin >> n >> m >> k;
    
   string s[n];
    f(i,n) cin >> s[i];
    
   int res = 0; 
    
   for(int i=0;i<(1LL<<(n+m));i++)
   {
       //1 black //3 red //2 white
    
       int col[n][m];
       f(j,n) f(k,m) 
           if(s[j][k] == '#') col[j][k] = 1;
           else col[j][k] = 0;
           
       f(j,n) if((i&(1LL<<j)))
           f(k,m) col[j][k] = 3;
        
       f(k,m) if((i&(1LL<<(k+n))))
           f(j,n) col[j][k] = 3;
       
       int temp = 0;
       f(j,n) f(k,m) if(col[j][k] == 1) temp++;
           
           if(temp == k) res++;
    
   }
    
   cout << res; 
}

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

Measured memory_bytes: 3664
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from copy import deepcopy
#import heapq
#import math
#import string
from fractions import gcd

setrecursionlimit(10**6)
input=stdin.readline

def factorization(num):
    ans=set()
    tmp=num
    for i in range(2,int(num**0.5)+1):
        while tmp%i==0:
            ans.add(i)
            tmp//=i
    if ans==[]:
        ans.add(num)
    elif tmp!=1:
        ans.add(tmp)
    return ans

a,b=map(int,input().split())
pa,pb=factorization(a),factorization(b)
pa.add(1);pb.add(1)

print(len(pa&pb))

Measured memory_bytes: 5088
#include<stdio.h>
#define N 101
int main(){
  int n,i,j,num;
  int k=1,m=0,sum=0;
  int a[N],f[N],G[N][N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&G[i][j]);
    }
  }
  f[0]=1;
  a[0]=0;
  for(i=1;i<n;i++) f[i]=0;
  while(1){
    num=2001;
    for(i=0;i<k;i++){
      for(j=0;j<n;j++){
    if(G[a[i]][j]<num && G[a[i]][j]!=-1 && f[j]!=1){
      num=G[a[i]][j];
      m=j;
    }
      }
    }
    if(k!=n){
      a[k]=m;
      f[m]=1;
      sum+=num;
      k++;
    }
    else break;
  }
  printf("%d\n",sum);
  return 0;
}





Measured memory_bytes: 2088
import java.io.*;
public class Main{
  public static void main(String[] args) throws IOException
  {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    
    String str1=br.readLine();
    String str2=br.readLine();
    
    int n=str1.length();
    int m=str2.length();
        
    int  dp[][]=new int[n+1][m+1];
     
        for(int i=0;i<=m;i++)
            dp[0][i]=0;
        for(int i=0;i<=n;i++)
            dp[i][0]=0;
        
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=m;j++)
            {

                if(str1.charAt(i-1)==str2.charAt(j-1))
                {
                    
                    dp[i][j]=1+dp[i-1][j-1];
                }
                else
                {
                	dp[i][j]=Math.max(dp[i][j-1], dp[i-1][j]);
                	
                }
            }
        }
        
        int i=n,j=m;
        StringBuilder res=new StringBuilder("");
        while(i>0&&j>0)
        {
        	if(str1.charAt(i-1)==str2.charAt(j-1))
        	{
        		res.append(str1.charAt(i-1));
        		i--;
        		j--;
        	}
        	else
        	{
        		if(dp[i][j-1]>dp[i-1][j])
        		{
        			j--;
        		}
        		else
        			i--;
        	}
        	
        }
        		
        
        System.out.println(res.reverse());
} 
}


Measured memory_bytes: 82636
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,m; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
int cnt = 0;
void dfs(int a) {
	vis[a] = true;
	rep(v, n) {
		if (graph[a][v] == 0) continue;
		if (vis[v]) continue;
		dfs(v);
	}
}

int main() {
	cin >> n >> m; vector<P> p(m);
	rep(i, m) {
		cin >> p[i].first >> p[i].second;
		p[i].first--; p[i].second--;
		graph[p[i].first][p[i].second]++;
		graph[p[i].second][p[i].first]++;
	}
	rep(i, m) {
		rep(i, n+1) vis[i] = false;
		graph[p[i].first][p[i].second]=0;
		graph[p[i].second][p[i].first]=0;
		dfs(0);
		bool bridge = false;
		rep(i, n) if (!vis[i]) bridge = true;
		if (bridge) cnt++;
		graph[p[i].first][p[i].second]++;
		graph[p[i].second][p[i].first]++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
N, M = map(int,input().split())

parent = [-1] * (N + 1)

def root(x):
	while parent[x] >= 0:
		x = parent[x]
	return x

def unite(x,y):
	root_x = root(x)
	root_y = root(y)

	if root_x != root_y :
		if parent[root_x] > parent[root_y] :
			parent[root_x]=root_y
		else :
			if parent[root_x] == parent[root_y] :
				parent[root_x] -= 1
			parent[root_y] = root_x
    
	return

for _ in range(M) :
	X, Y, Z = map(int, input().split())
	unite(X, Y)
	
print(sum(i < 0 for i in parent) - 1)

Measured memory_bytes: 5456
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	vi a(n);
	int mn = INF, mx = -INF;
	int mna = 0, mxa = 0;

	rep(i, n) {
		cin >> a[i];
		mx = max(mx, a[i]);
		if (mx == a[i])mxa = i;
		mn = min(mn, a[i]);
		if (mn == a[i])mna = i;
	}

	V<P> ans(0);
	bool p = true;
	if (abs(mn) > abs(mx))p = false;

	if (p) {
		rep(i, n)ans.push_back(P(mxa + 1, i + 1));
		rep(i, n - 1)ans.push_back(P(i + 1, i + 2));
	}
	else {
		rep(i, n)ans.push_back(P(mna + 1, i + 1));
		rep(i, n - 1)ans.push_back(P(n - i, n - 1 - i));
	}
	
	cout << ans.size() << endl;
	for (auto x : ans)cout << x.first << " " << x.second << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
typedef long long ll;
using namespace std;
typedef pair<int,int> P;
const int p[]={-1,0,1,0};
const int v[]={0,-1,0,1};

int main(){
  int h,w; cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];

  int ans=0;
  
  rep(i,h)rep(j,w){
      if(s[i][j]=='#') continue;
      vector<vector<int>> d(h,vector<int>(w,-1));
      queue<P> wa;

      auto kyu=[&](int a, int b, int x){
          if(d[a][b]!=-1) return;
          d[a][b] = x;
          wa.push(P(a,b));
      };
      
      kyu(i,j,0);
      while(!wa.empty()){
          int nowi=wa.front().first;
          int nowj=wa.front().second;
          wa.pop();
         rep(dir,4){
             int ni=nowi+p[dir]; int nj=nowj+v[dir];
             if(ni<0||ni>=h||nj<0||nj>=w) continue;
             if(s[ni][nj]=='#') continue;
             kyu(ni,nj,d[nowi][nowj]+1);
         }
      }
    rep(aa,h)rep(bb,w){
        ans=max(ans,d[aa][bb]);
    }
  }
  cout << ans << endl;
 return 0;
}


Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// g++ hoge.cpp -std=c++17 -I . でコンパイルできる
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#include <atcoder/all>

#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
using namespace atcoder;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;



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

    int a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    int k;
    int g,e;
    ll q;
    cin>>n>>q;
    fenwick_tree<ll> tree(n);
    rep(i,n){
        cin>>a;
        tree.add(i,a);
    }
    rep(i,q){
        cin>>a;
        if(a==0){
            cin>>a>>b;
            tree.add(a,b);
        }else{
            cin>>a>>b;
            cout<<tree.sum(a,b)<<endl;
        }
    }

    return 0;
}


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

using namespace std;

int main()
{
	vector < int >M(5);
	for (int i = 0; i < 5; i++) {
		cin >> M[i];
	}

	int ans = 0;
	int s = 0;
	for (int i = 0; i < 5; i++) {
		ans += M[i];
		if (M[i] % 10 != 0) {
			int t = 10 - M[i] % 10;
			ans += t;
			if (s < t) {
				s = t;
			}
		}
	}

	cout << ans - s << endl;
	return 0;
}


Measured memory_bytes: 256
while True:
    s=input()
    if s=='0':
        break
    else:
        s2=input()
        s3=input()
        p=[s,s2,s3]
        for i in range(3):
            a=0
            b=0
            for k in range(1,len(p[i])):
                if p[i][k]=='A':
                    a+=1
                else:
                    b+=1
            if i==2:
                if a>b:
                    a+=1
                else:
                    b+=1
            
            else:    
                if p[i+1][0]=='A':
                    a+=1
                else:
                    b+=1
            print(a,b)        


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

int main() {
    int N, M;
    cin >> N >> M;
    int sum = 0;
    vector<int> A(M);
    for(int i = 0; i < M; i++) {
        cin >> A[i];
        sum += A[i];
    }
    if(sum > N) {
        cout << "-1" << endl;
    }
    else {
        cout << N - sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

/***************/

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}
#define ll long long
ll gcd (ll a, ll b) {
    while (b > 0) {
        ll t = a % b;
        a = b, b = t;
    }
    return a;
}

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

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (!(a & 1) || !(b & 1) || !(c & 1)) {
        cout << 0 << endl;
    } else {
        int arr[3] = {a, b, c}; sort(arr, arr+3);
        cout << 1LL * arr[0] * arr[1] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

void insertion_sort(int *data, int n)
{
	for(int i = 1; i < n; i++) {
		int v = data[i];
		int j = i - 1;
		while(j >=0 && data[j] > v) {
			data[j+1] = data[j];
			j--;
		}
		data[j+1] = v;
		for(int i = 0; i < n; i++) {
			printf("%d", data[i]);
			if(i != n-1) {
				printf(" ");
			} else {
				printf("\n");
			}
		}
	}
}

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

	int *data;
	data = new int[n];

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

	for(int i = 0; i < n; i++) {
		printf("%d", data[i]);
		if(i != n-1) {
			printf(" ");
		} else {
			printf("\n");
		}
	}
	insertion_sort(data, n);
	delete data;
	return 0;
}


Measured memory_bytes: 3116
//
// ABC057C : Digits in Multiplication
//
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
using namespace std;

int F(int a, int b) {
	string a1 = to_string(a);
	string b1 = to_string(b);
	return max(a1.size(), b1.size());
}


int main() {
	long long N,A,B;
	cin >> N;

	long long max1 = sqrt(N) / 1;
	int ans = to_string(N).size();

	for(A=max1; A>=1; A--) {
		if (N % A == 0) {
			B = N / A;
			int digits = F(A,B);
			if (digits < ans) { ans = digits; }
		}

	}
	cout << ans << endl;
		return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
tour = [1]
gone = [0] * (N+1)

for i in range(N):
    now = tour[-1]
    if gone[now]:
        save = now
        break
    gone[now] = 1
    tour.append(A[now])

save_idx = tour.index(save)

if K <= save_idx:
    print(tour[K])
    exit()

loop = tour[save_idx+1:]
K = K - save_idx - 1
print(loop[K % len(loop)])


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

int main(){
	
	map < char , int > count;
	
	string mozi;
	
	while(cin>>mozi){
		
		for(int i=0;i<(int)mozi.size();i++){
		
		if(isupper(mozi[i])){
		mozi[i] = tolower(mozi[i]);
		}
		}
		
		for(int i=0;i<(int)mozi.size();i++){
		
		count[mozi[i]]++;		
			
		}
	}
		for(char ch='a';ch<='z';ch++){
			cout<<ch<<" : "<<count[ch]<<endl; 
			
		}
	return 0;
}


Measured memory_bytes: 3164
import itertools
import collections
import sys
N=int(input())
if N==1:
    print(1)
    sys.exit()
X=[0]*N
Y=[0]*N
for i in range(N):
    X[i],Y[i]=[int(x) for x in input().split()]
p=[]
for c in list(itertools.permutations(zip(X,Y), 2)):
    p.append(str(c[1][0]-c[0][0]) + ',' +str(c[1][1]-c[0][1]))
    #print(c,c[1][0]-c[0][0],c[1][1]-c[0][1])
#print(p)
print(N - collections.Counter(p).most_common()[0][1])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
vector<ll>v;
ll par[200100];
ll vis[200100];
ll flag=0;
ll ans;
ll dfs(ll x,ll rem)
{
    if(rem==0)
    {
        flag=1;
        ans=x;
        return 0;
    }
    vis[x]+=1;
    if(vis[x]==2)
    {
        v.push_back(x);
        return dfs(par[x],rem-1);
    }
    if(vis[x]==3)
    {
        return rem;
    }
    return dfs(par[x],rem-1);
}
int main() {
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    for(ll i=1;i<=n;i++)
        cin>>par[i];
    ll rem=dfs(1,k);
    if(flag==1)
    {
        cout<<ans;
        return 0;
    }
    cout<<v[rem%(v.size())];
}

Measured memory_bytes: 15892
#include <bits/stdc++.h>
#define ll long long
#define all(x) begin(x), end(x)
#define print(x) for (auto &el: x) cout << el << ' '; cout << '\n'
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    
    string s;
    cin >> s;

    ll k = 0;
    for (auto el: s) {
        k += el - '0';
    }

    if (k % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 3764
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2020/03/01.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {
	ll ans = 0;

	ll n;
	cin >> n;

	ans = n / 2;
	
	if ((n % 2) == 1) {
		ans++;
	}
	
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
//#define P pair<int, int>

using namespace std;
using ll = __int64_t;

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

void solve(){
  int n;
  ll count = 0;
  cin >> n;
  ll a[n];
  rep(i, n) cin >> a[i];
  
  rep(i, n){
    while(a[i]%2 == 0){
      a[i] /= 2;
      count++;
    }
  }
  cout << count << endl;
}

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


Measured memory_bytes: 384
fun solve(n:Int){
    var ans = "No"
    for(i in 1 until 10){
        if(n%i ==0 && (n/i) in 1..9){
            ans = "Yes"
        }
    }
    println(ans)
}

fun main(){
    val n = readLine()!!.toInt()
    solve(n)
}

Measured memory_bytes: 34480
import copy
n = int(input())
x = list(map(int,input().split()))
x2 = copy.copy(x)
x2.sort()
num1,num2 = (len(x)//2)-1,(len(x)//2)
med1,med2 = x2[num1],x2[num2]
for i in range(n):
	if x[i] <= med1:
		print(med2)
	else:
		print(med1)

Measured memory_bytes: 32512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int gcd(int x, int y){
  if(x<y) swap(x, y);
  while(y!=0){
    int z=x%y;
    x=y;
    y=z;
  }
  return x;
}

int main(){
  int n,k;
  cin>>n>>k;
  int M=-1, G=0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    M=max(M,x);
    G=gcd(x,G);
  }
  if(k<=M&&k%G==0){
    cout<<"POSSIBLE"<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] x = new int[N];
		for(int i = 0; i < N; i++) 
			x[i] = sc.nextInt();
		int[] y = x.clone();
		Arrays.sort(y);
		for(int i = 0; i < N; i++) {
			if(x[i] <= y[N/2-1])
				System.out.println(y[N/2]);
			else
				System.out.println(y[N/2-1]);
		}
		
	}

}

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

int main()
{
    int n;
    cin >> n;
    vector<int> ans(n);
    for (int i = 0; i < n-1; i++)
    {
        int t;
        cin >> t;
        ans[t-1]++;
    }
    for (int i = 0; i < n; i++)
        cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 4008
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
struct edge{int to,cost,d;};
using P=pair<pair<int,int>,int>;
const int INF=1<<29;
const int MAX_V=110;
const int MAX_L=110;
vector<edge> G[MAX_V];
int d[MAX_L][MAX_V];
int V,E,L;
//O(E*L*logV)
void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P>> que;
  REP(i,110)
    fill(d[i],d[i]+V,INF);
  d[0][s]=0;
  que.push(P(make_pair(0,0),s));
  while(!que.empty()){
    P p=que.top();que.pop();
    int v=p.second;
    if(d[p.first.second][v]<p.first.first)continue;
    REP(i,G[v].size()){
      edge e=G[v][i];
      //attacked
      if(d[p.first.second][e.to]>d[p.first.second][v]+e.cost){
	d[p.first.second][e.to]=d[p.first.second][v]+e.cost;
	que.push(P(make_pair(d[p.first.second][e.to],p.first.second),e.to));
      }
      //not attacked
      int used=p.first.second+e.d;
      if(used<=L){
	if(d[used][e.to]>d[p.first.second][v]){
	  d[used][e.to]=d[p.first.second][v];
	  que.push(P(make_pair(d[used][e.to],used),e.to));
	}
      }
    }
  }
}

int main(){ _;
  int n,m,l,a,b,dist,thief;
  while(cin>>n>>m>>l,(n|m|l)!=0){
    V=n;E=m;L=l;
    REP(i,V)G[i].clear();
    REP(i,m){
      cin>>a>>b>>dist>>thief;
      a--;b--;
      G[a].push_back(edge{b,thief,dist});
      G[b].push_back(edge{a,thief,dist});
    }
    dijkstra(0);
    int result=INF;
    REP(i,l+1)
      if(result>d[i][n-1])
	result=d[i][n-1];
    cout<<result<<endl;
  }
}

Measured memory_bytes: 3464
#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 <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};

typedef struct _node{
  ll key;
  _node *next;
}node;


const int hashMod=437935;
node ent[10000000];
int sz;
node* hash[hashMod];

void insert(ll key){
  int ha=key%hashMod;
  for(node*p=hash[ha];p;p=p->next){
    if(p->key==key)return;
  }
  node*p=hash[ha];
  hash[ha]=ent+sz++;
  hash[ha]->key=key;
  hash[ha]->next=p;
}

bool count(ll key){
  int ha=key%hashMod;
  for(node*p=hash[ha];p;p=p->next){
    if(p->key==key)return true;
  }
  return false;
}

int n,m;
int sx,sy;

bool get(ll st,int x,int y){
  return (st>>x*m+y)&1;
}

void pr(ll st,int x,int y){
  rep(i,n){
    rep(j,m){
      if(i==x && j==y)cout<<2<<' ';
      else cout<<get(st,i,j)<<' ';
    }
    cout<<endl;
  }
  cout<<endl;
}

bool cancut(ll st,int x,int y){
  //pr(st,x,y);
  rep(i,n)rep(j,m){
    if((i==sx && j==sy) ||
       get(st,i,j))continue;
    int ne0=0;
    rep(k,4){
      int nx=i+dx[k],ny=j+dy[k];
      if((0>nx || nx>=n ||
         0>ny || ny>=m ||
          get(st,nx,ny)) &&
         nx!=x && ny!=y)continue;
      ++ne0;
    }
    if(ne0<2){
      //cout<<i<<' '<<j<<' '<<ne0<<' '<<get(st,i,j)<<endl;
      //cout<<"true"<<endl;
      return true;
    }
  }
  //cout<<"false"<<endl;
  return false;
}

bool dfs(ll st,int x,int y,int b){
  //pr(st,x,y);
  if(abs(x-sx)+abs(y-sy)>b)return false;  
  if(b==0 && x==sx && y==sy)return true;
  ll ast=st|ll(x)<<51LL|ll(y)<<56LL;
  if(count(ast))return false;
  insert(ast);

  if(cancut(st,x,y))return false;
  
  rep(i,4){
    int nx=x+dx[i],ny=y+dy[i];
    if(0>nx || nx>=n ||
       0>ny || ny>=m ||
       get(st,nx,ny))continue;
    ll nst=st|1LL<<nx*m+ny;
    if(dfs(nst,nx,ny,b-1))return true;
  }
  return false;
}

void solve(){
  sz=0;
  memset(hash,0,sizeof(hash));
  ll st=0;
  int bu=0;
  rep(i,n){
    rep(j,m){
      ll t;
      cin>>t;
      st|=t<<i*m+j;
      bu+=t;
    }
  }
  rep(i,n)rep(j,m){
    if(get(st,i,j))continue;
    sx=i;
    sy=j;
    break;
  }

  if(n*m!=bu && (n*m-bu)%2==0 && dfs(st,sx,sy,n*m-bu))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

main(){
  while(cin>>m>>n,n|m)solve();
}

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

typedef long long ll;

int main()
{
    int i,j,k;
    int n,x;
    while(true){
        cin >> n >> x;
        if(n == 0 && x == 0){
            return 0;
        }
        ll ans = 0;
        for(i = 1;i <= n-2;++i){
            for(j = i+1;j <= n-1;++j){
                for(k = j+1;k <= n;++k){
                    int temp = i+j+k;
                    if(temp == x){
                        ++ans;
                    }else if(temp > x){
                        break;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
N, K = map(int, input().split())
x = [int(i) for i in input().split()]
ans = float('inf')
for i in range(N-K+1):
    l = x[i]
    r = x[i+K-1]
    a = abs(l) + abs(r - l)
    b = abs(r) + abs(r - l)
    ans = min(a,b,ans)
print(ans)

Measured memory_bytes: 14392
#include <iostream>

using namespace std;

int main(void) {
  int S,K;
  cin >> K >> S;

  int count = 0;
  for(int x=0; x <= K; x++) {
    for(int y=0; y <= K; y++) {
      int z = S - x - y;
      if (0 <= z && z <= K) {
        count++;
      }
      // for(int z=0; z <= K; z++) {
      //   if (x+y+z == S) {
      //     count++;
      //   }
      // }
    }
  }

  cout << count << endl;
}


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

int main(){ 
    int n;
    cin>>n;
    int a=n;
    vector<int> b(n);
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=1;i<n;i++){
    for(int j=1;j<i+1;j++){
        if(b[i-j]<=b[i]){
        }else{a--;
            break;
        }
        
    }}
    cout<<a;
    return 0;
}


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

using namespace std;

int main ()
{
  int n, k;
  cin >> n >> k;
  
  vector<int> v(n);
  for(int& x: v) cin >> x;
  
  sort (v.begin(), v.end());
  
  int ans = 0;
  for(int i=0; i<k; ++i) ans += v[i];
  cout << ans;
}

Measured memory_bytes: 3596
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    X = list(map(int, input().split()))

    X.sort()
    ans = float("inf")
    for l in range(N - K + 1):
        r = l + K - 1
        l2r = abs(X[l]) + abs(X[l] - X[r])
        r2l = abs(X[r]) + abs(X[r] - X[l])
        ans = min(ans, l2r, r2l)

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int res = 1;
  char ns = S[0];
  for (int i = 0; i < N; i++) {
    if (ns != S[i]) {
      ns = S[i];
      res++;
    }
  }
  cout << res << '\n';
  return 0;
}


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

int main() {
    ll n, d;
    cin >> n >> d;
    int cnt = 0;
    for (int i = 0; i < n; i++){
        ll x, y;
        cin >> x >> y;
        if (x*x + y*y <= d*d) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
#define N (100000+1000)
using namespace std;

long long vis[N],prime[N],cnt,n,x,a[N],b[N];
map<long long,long long>Map;

void Init(int n)
{
	for (int i=2; i<=n; ++i)
	{
		if (!vis[i]) prime[++cnt]=i;
		for (int j=1; j<=cnt && prime[j]*i<=n; ++j)
		{
			vis[prime[j]*i]=true;
			if (i%prime[j]==0) break;
		}
	}
}

long long sqr(long long x){return  x*x;}

int main()
{
	Init(3000);
	scanf("%lld",&n);
	for (int i=1; i<=n; ++i)
	{
		scanf("%lld",&x);
		for (int j=1; j<=cnt; ++j)
			while (x%(prime[j]*prime[j]*prime[j])==0)
				x/=prime[j]*prime[j]*prime[j];
		Map[x]++; a[i]=x;
		long long y=1;
		for (int j=1; j<=cnt; ++j)
			if (x%prime[j]==0)
			{
				y*=x%(prime[j]*prime[j])==0?prime[j]:prime[j]*prime[j];
				while (x%prime[j]==0) x/=prime[j];
			}
		if (sqr((long long)sqrt(x))==x) y*=(long long)sqrt(x);
		else y*=x*x;
		b[i]=y;
	}
	long long ans=0;
	if (Map[1]) ans++; Map[1]=0;
	for (int i=1; i<=n; ++i)
	{
		ans+=max(Map[a[i]],Map[b[i]]);
		Map[a[i]]=Map[b[i]]=0;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 14336
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for(int i = 0 ; i < 3 ; i++){
            a[i] = sc.nextInt();
        }
        sc.close();
        Arrays.sort(a);
        System.out.println(a[0] + a[1] + a[2] * 10);
    }
}

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

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

  vector<int> P(N);
  for(int i = 0; i < N; i++){
    cin >> P[i];
  }

  int ans = 0, prev_min = N;
  for(int i = 0; i < N; i++){
    if(P[i] <= prev_min){
      prev_min = P[i];
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
# frozen_string_literal: true

A, B = gets.chomp.split(" ").map { |i| i.to_i }
if (A + B) % 2 == 0 then
C = (A + B ) / 2 
puts C
elsif(A + B) % 2 != 0 then
    C = (A + B ) / 2 + 1
    puts C
end


Measured memory_bytes: 1788
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
class Main {
	public static void main (String[] args)   {
	   Scanner s=new Scanner(System.in); 
        String str=s.next();
        if(str.charAt(5)==str.charAt(4) && str.charAt(3)==str.charAt(2))
        System.out.println("Yes");
        else
         System.out.println("No");
	   
	    
 
	}
	
}


Measured memory_bytes: 22612
A,B,C = map(int,input().split())
N = int(input())
stack = [(A,B,C,N)]
flag = False
while stack:
  a,b,c,n = stack.pop()
  if a<b and b<c:
    flag = True
    break
  if n>0:
    stack.append((a*2,b,c,n-1))
    stack.append((a,b*2,c,n-1))
    stack.append((a,b,c*2,n-1))
print('Yes') if flag else print('No')



Measured memory_bytes: 9200
#include <iostream>

using namespace std;

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

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

    int min = 1000000000;
    for ( int P = 1; P <= 100; P ++ ) {
        int sum = 0;
        for ( int i = 0; i < N; i ++ ) {
            sum += ( (P-X[i]) * (P-X[i]) );
        }
        if ( sum < min ) min = sum;
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

hands = ['r', 's', 'p']
for i,t in enumerate(T):
    if t == 'r':
        T[i] = 'p'
    elif t == 's':
        T[i] = 'r'
    else:
        T[i] = 's'
point = 0
for i,t in enumerate(T):
    if i+1 <= K:
        if t == 'r':
            point += R
        elif t == 's':
            point += S
        else:
            point += P
        continue
    if t == T[i-K]:
        a = 0
        if len(T)-1 < i+K:
            next_hand = T[i]
        else:
            next_hand = T[i+K]
        while T[i] == T[i-K] or T[i] == next_hand:
            T[i] = hands[a]
            a += 1
    else:
        if t == 'r':
            point += R
        elif t == 's':
            point += S
        else:
            point += P
print(point)

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

int main () {
  /*
  vector<vector<string>> data(2, vector<string>(3));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> data.at(i).at(j);
    }
  }
  */
  /*
  vector<string> A(1);
  cin >> A;
  vector<string> B(1);
  cin >> B;

  string answerb = "";
  answerb = reverse(B.begin(), B.end());
  if (A == answerb) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << end;
  }
  */
  string A, B;
  cin >> A >> B;

  //cout << A.size() << B.size() << endl;
  if (A.at(0) == B.at(2)) {
    if (A.at(1) == B.at(1)) {
      if (A.at(2) == B.at(0)) {
        cout << "YES" << endl;
      }
      else {
        cout << "NO" << endl;
      }
    }
    else {
      cout << "NO" << endl;
    }    
  }
  else {
    cout << "NO" << endl;
  }  
}


Measured memory_bytes: 256
class Price(value: Double, currency: String) {
  val bitCoinToYenRate = 380000

  def toYen(): Double = {
    currency match {
      case "JPY" => value
      case "BTC" => value * bitCoinToYenRate
      case _ => throw new IllegalStateException(s"invalid currency received: ${currency}")
    }
  }
}


object Main extends App {
  import io.StdIn._

  val otosidamaCount = readInt()
  var readCount = 0
  var total: Double = 0
  do {
    val input = readLine().split(' ')
    val yen = new Price(input(0).toDouble, input(1)).toYen()
    total += yen
    readCount += 1
  } while(readCount < otosidamaCount)

  println(f"$total%f")
}


Measured memory_bytes: 54776
import java.util.*;

public class Main {
  public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
	  int N = Integer.parseInt(sc.next());
	  int X = Integer.parseInt(sc.next());
	  
	  int D = 0;
	  int count = 1;
	  for(int i = 0; i < N; i++) {
		  D += Integer.parseInt(sc.next());
		  if(D <= X)
			  count++;
		  else
			  break;
		  
	  }
	  System.out.println(count);
	  sc.close();
	  
  }
}


Measured memory_bytes: 21204
n = int(input())
a = [input() for _ in range(n)]
a0 = a[0]
for i in range(1,n):
    if a[i][0] == a0[-1]:
        flag = True
    else:
        flag = False
        break
    a0 = a[i]
if len(set(a)) == len(a) and flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h>

int Addition(int N) {
	int out = 0;
	int n = N;
	while (n > 0) {
		out += n % 10;
		n /= 10;
	}
	return out;
}

int main() {
	int inputN;
	int Sn;

	scanf("%d", &inputN);

	Sn = Addition(inputN);

	if (inputN%Sn == 0)printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

	int mini = 999;
	int score = 0;
	for (int i = 0; i < n; i++) {
		cin >> s;
		score += s;
		if (s % 10 > 0 && mini > s) {
			mini = s;
		}
	}

	if (score % 10 == 0) {
		if (mini == 999) {
			score = 0;
		} else {
			score -= mini;
		}
	}

	cout << score << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())

B = list(map(int, input().split()))

ans = 0
for i in range(N):
    if i == 0:
        ans += B[i]
    elif i == N - 1:
        ans += B[i - 1]
    else:
        ans += min(B[i], B[i - 1])

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

int n, k;
int a[200000];
ll b[200000];
ll mem[32];

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
	int w = k, p = 0;
	while (w != 0) {
		++p;
		w /= 2;
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] > k) continue;
		bool flag = true;
		for (int j = 0; j < p; ++j) {
			flag = flag && (((k & (1 << j)) >= 1) || ((a[i] & (1 << j)) == 0));
		}
		if (flag) ans += b[i];
	}
	for (int e = 0; e < p; ++e) {
		if ((k & (1 << (e + 1))) == 0) continue;
		int bit = ((k | ((1 << (e + 1)) - 1)) & ~(1 << (e + 1)));
		ll res = 0;
		for (int i = 0; i < n; ++i) {
			if (a[i] > bit) continue;
			bool flag = true;
			for (int j = 0; j < p; ++j) {
				flag = flag && (((bit & (1 << j)) >= 1) || ((a[i] & (1 << j)) == 0));
			}
			if (flag) res += b[i];
		}
		ans = max(ans, res);
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 1408
#include <stdio.h>

int main(void) {
  int n = 0;
  int i = 1;
  int x = 0;

  scanf("%d", &n);

  do {
    x = i;

    if ((x % 3) == 0) {
      printf(" %d", i);
      continue;
    }

    do {
      if ((x % 10) == 3) {
	printf(" %d", i);
	break;
      }

      x /= 10;
    } while (x);
  } while (++i <= n);

  printf("\n");
  
  return 0;
}

Measured memory_bytes: 600
K, N = map(int,input().split())
A = list(map(int,input().split()))
ans = [0] * N
for i in range(N-1):
    ans[i] = A[i+1] - A[i]
ans[N-1] = K - A[N-1] + A[0]
print(K - max(ans))

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

int main() {
  int N,K;
  cin >> N >> K;
  
  vector<int> tree(N);
  //木の高さ
  
  for(int i=0;i<N;i++){
    cin >>tree.at(i);
  }
  
  sort(tree.begin(),tree.end());
  //小さい方からに並び替え

  vector<int> dif(N-1);
  //n番目に小さいのとn+1番目に小さいのの差

  for(int j=0;j<N-1;j++){
    dif.at(j)=tree.at(j+1)-tree.at(j);
  }
  
  vector<int> hdif(N-K+1);
  //K個内でのMAX-minの候補
  
  int m=0;
  
  for(int k=0;k<N-K+1;k++){
    int a=0;
    for(int l=0;l<K-1;l++){
      a+=dif.at(l+m);
    }
    hdif.at(k)=a;
    m++;
  }
  
  sort(hdif.begin(),hdif.end());
  int b = hdif.at(0);
  cout << b <<endl;
}


Measured memory_bytes: 1408