akhauriyash/Code-Regression huggingface dataset:
N = int(input())
l = ""
i = 1

while True:
    x = i
    # CHECK_NUM
    if x%3 == 0:
        l += " {}".format(i)

    # INCLUDE3
    else:
        while True:
            if x%10 == 3:
                l += " {}".format(i)
                break
            x //= 10
            if x < 1:
                break
    i += 1
    if i > N:
        print(l)
        break




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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int n, q;
int bit[26][500005];

int sum(char c, int i) {
    int s = 0;
    while (i > 0) {
        s += bit[c-'a'][i];
        i -= i & -i;
    }
    return s;
}

void add(char c, int i, int x) {
    while (i <= n) {
        bit[c-'a'][i] += x;
        i += i & -i;
    }
}

int main(void) {
    string s = "x", t;
    cin >> n >> t >> q;
    s += t;
    rep(i, 1, n+1) {
        add(s[i], i, 1);
    }
    rep(i, 0, q) {
        int cmd;
        scanf("%d", &cmd);
        if (cmd==1) {
            char c;
            int idx;
            cin >> idx >> c;
            if (s[idx]!=c) {
                add(s[idx], idx, -1);
                add(c, idx, 1);
                s[idx] = c;
            }
        } else {
            int l, r;
            cin >> l >> r;
            int s = 0;
            for (char c = 'a'; c <= 'z'; c++) s += ((sum(c, r) - sum(c, l-1)) > 0);
            printf("%d\n", s);
        }
    }

	return 0;
}


Measured memory_bytes: 52228
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n-1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];

    int ans = b[a[0] - 1];
    for (int i = 1; i < n; ++i) {
        ans += b[a[i] - 1];
        if (a[i-1] == a[i] - 1) {
            ans += c[a[i-1]-1];
        }
    }

    cout << ans << endl;
}


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

 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	vector<long long>v;
	v.push_back(a*c);
	v.push_back(a*d);
	v.push_back(b*c);
	v.push_back(b*d);
	cout<<*max_element(v.begin(),v.end())<<"\n";




	 

	
	

	



	

	



	


 
	
	
	
	
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

    
    int N;
    cin >> N;
    ll a = 0, b, ans = 0;
    for(int i = 0; i < N; i++){
        cin >> b;
        ans += (a + b) / 2;
        //cout << a << " " << b << " " << ans << endl;
        if(a == 0){
            a = b%2;
        }
        else{
            if(b == 0)a = 0;
            else a = (1 + b)%2;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int32 N;
	while(cin >> N && N){
		vector<int32> x(N);
		REP(i, N) cin >> x[i];
		int32 res = INF;
		sort(all(x));
		REP(i, N-1) res = min(res, x[i+1]-x[i]);
		cout << res << endl;
	}
}


Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>
#include <iomanip>

using namespace std;
typedef long long ll;
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


vector<vector<int>> to(2100);
vector<vector<int>> ot(2100);
vector<bool> fromS(1100);
vector<bool> fromG(1100);
struct edge{
	int from;
	int to;
	ll cost;
};
void dfs(int now){
    if(fromS[now])return;
    fromS[now]=true;
    for(int next:to[now]){
        dfs(next);
    }
}
void rdfs(int now){
    if(fromG[now])return;
    fromG[now]=true;
    for(int next:ot[now]){
        rdfs(next);
    }
}

int main(){
	int n,m;cin>>n>>m;
	vector<edge> edges(m);
	rep(i,m){
		int a,b;cin>>a>>b;
		--a,--b;
		ll c;cin>>c;
		edges[i]={a,b,c};
		to[a].push_back(b);
		ot[b].push_back(a);
	}
	vector<bool> ok(n);
	dfs(0);
	rdfs(n-1);
	rep(i,n)ok[i]=(fromS[i]&&fromG[i]);
	ll INF =1e18;
	vector<ll> res(n,-INF);
	res[0]=0;
	rep(i,n){
		bool upd=false;
			rep(j,m){
				edge e=edges[j];
				if(!ok[e.from]||!ok[e.to])continue;
				if(res[e.from]==-INF)continue;
				if(res[e.to]<res[e.from]+e.cost){
					res[e.to]=res[e.from]+e.cost;
					upd=true;
					if(i==n-1){
					    cout<<"inf"<<endl;
					    return 0;
					}
				}
			}
		if(!upd)break;
	}
	cout<<res[n-1]<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, T;
    cin >> n >> T;
    int mx = 0;
    for(register int i = 1; i <= T; ++i)
    {
        int x;
        cin >> x;
        mx = max(mx, x);
    }
    cout << max(mx - 1 - (n - mx), 0) << endl;
} 

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
n = int(input())
G = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append([b,i])

ans = [None]*(n-1)
def rec(cur,color):

    cnt = 1
    for (to, j) in G[cur]:
        if cnt == color:
            cnt += 1
        ans[j] = cnt
        rec(to, cnt)
        cnt += 1
rec(0, 0)
print(max(ans))
print(*ans, sep="\n")


Measured memory_bytes: 70928
#include <iostream>
#include <string>
int main(){
    int n;
    std::string S;
    std::cin>>n>>S;
    int ans=0;
    int x=0;
    for(int i=0;i<n;++i){
        if(S[i]=='I') x++;
        else x--;

        if(x>ans) ans=x;
    }
    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 256
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <cassert>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=(a%10/5)+(a%5), a/=10; return res;}

int main() {
  int n,m; cin>>n>>m;
  vector<int> v[n]; int ed[n]={};
  for(int i=0;i<m;i++) {
    int x,y; cin>>x>>y; x--; y--;
    v[x].push_back(y); ed[y]++;
  }
  int val[n]={};
  queue<int> que;
  for(int i=0;i<n;i++) {
    if (ed[i] == 0) que.push(i);
  }
  while(!que.empty()) {
    int from = que.front(); que.pop();
    for(int to : v[from]) {
      chmax(val[to],val[from]+1);
      if (--ed[to] == 0) {
        que.push(to);
      }
    }
  }
  int an = 0;
  for(int i=0;i<n;i++) {
    chmax(an,val[i]);
  }
  cout<<an<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest

Measured memory_bytes: 9720
import java.util.Scanner;
public class Main {
	static Node r;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x;
		int y;
		String com;
		int cnt=0;
		for(int i=0; i<n; i++){
			com = sc.next();
			if(com.equals("insert")){
				x = sc.nextInt();
				y = sc.nextInt();
				r = insert(r, x, y);
				
			} else if (com.equals("find")){
				x = sc.nextInt();
				if(find(r, x) != null) System.out.println("yes");
				else System.out.println("no");
				
			} else if (com.equals("delete")){
				x = sc.nextInt();
				r = delete(r, x);
				
			} else if (com.equals("print")){
				inorder(r);
				System.out.println();
				preorder(r);
				System.out.println();
			}
		}
	}
	
	static Node delete(Node t, int key){
		if (t == null) return null;
		if (key < t.key) t.l = delete(t.l, key);
		else if (key > t.key) t.r = delete(t.r, key);
		else return _delete(t, key);
		return t;
	}
	
	static Node _delete(Node t, int key){
		if (t.l == null && t.r == null) return null;
		else if (t.l == null) t = leftRotate(t);
		else if (t.r == null) t = rightRotate(t);
		else {
			if (t.l.priority > t.r.priority) t = rightRotate(t);
			else t = leftRotate(t);
		}
		return delete(t, key);
	}
	
	
	static Node find(Node u, int k){
		while (u != null && k != u.key){
			if(k < u.key) u = u.l;
			else u = u.r;
		}
		return u;
	}
	
	static Node insert(Node t, int key, int priority){
		if (t == null) return new Node(key, null, null ,null, priority);
		if (key == t.key) return t;
		if (key < t.key){
			t.l = insert(t.l, key, priority);
			if (t.priority < t.l.priority) t = rightRotate(t);
		} else {
			t.r = insert(t.r, key, priority);
			if (t.priority < t.r.priority) t = leftRotate(t);
		}
		return t;
	}
	
	static Node rightRotate(Node t){
		Node s = t.l;
		t.l = s.r;
		s.r = t;
		return s;
	}
	
	static Node leftRotate(Node t){
		Node s = t.r;
		t.r = s.l;
		s.l = t;
		return s;
	}

	static void inorder(Node u){
		if (u == null) return;
		inorder(u.l);
		System.out.print(" " + u.key);
		inorder(u.r);
	}
	static void preorder(Node u) {
		if (u == null) return;
		System.out.print(" " + u.key);
		preorder(u.l);
		preorder(u.r);
	}
}


class Node {
    int key;
    Node p = null;
	Node l = null;
	Node r = null;
	int priority;
    public Node(int key, Node p, Node l, Node r, int priority) {
    	this.key = key;
        this.l = l;
        this.r = r;
        this.p = p;
        this.priority = priority;
    }
}


Measured memory_bytes: 183812
PROGRAM management
      IMPLICIT NONE
      integer(16) :: n
      integer(16) :: a(2:2*(10**5)),ans(2:2*(10**5))
      integer(16) :: i
      
      read*,n
      read*,a(2:n)
      
      ans(:) = 0
      do i = 1,n
        ans(a(i)) = ans(a(i)) + 1
      end do
      
      do i = 1,n
        print*,ans(i)
      end do
      
      
      END PROGRAM

Measured memory_bytes: 15484
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<(n);++i)
typedef long long int ll;

class BRollerCoaster {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n,k;
        in >> n >> k;

        int ans=0;
        rep(i,n){
            int t;
            in >> t;
            if(t>=k)ans++;
        }
        out << ans << endl;
	}
};


int main() {
	BRollerCoaster solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
// typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;
static const double pi = 3.141592653589793;

int main(){

	double a, b; cin>> a >> b; 
	double h, m; cin >> h >> m;
	double ta = (double(int(h)%12) + m / 60) / 12;
	double tb = m / 60;
	double theta = abs(ta - tb) * 2 * pi;
	double c = a * a + b * b - 2 * a * b * cos(theta);
	printf("%.12f", sqrt(c));
}	

Measured memory_bytes: 4260
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R')count+=1;
    }
    if(count>n/2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		
		int a, b, c, d, n = Integer.valueOf(reader.readLine());
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		
		for(int i = 0; i < n; i++) map.put(i + 1, 0);
			
		for(int i = 0; i < n * (n - 1) / 2; i++){
			string = reader.readLine();
			a = Integer.parseInt(string.split(" ")[0]);
			b = Integer.parseInt(string.split(" ")[1]);
			c = Integer.parseInt(string.split(" ")[2]);
			d = Integer.parseInt(string.split(" ")[3]);
			
			if(c == d){
				map.put(a, map.get(a) + 1);
				map.put(b, map.get(b) + 1);
			}else if(c > d){
				map.put(a, map.get(a) + 3);
			}else{
				map.put(b, map.get(b) + 3);
			}
		}
		ArrayList<Map.Entry<Integer, Integer>> entries = new ArrayList<Map.Entry<Integer, Integer>>(map.entrySet());
		Collections.sort(entries, new Comparator<Map.Entry<Integer, Integer>>() {
	 
			@Override
			public int compare(
					Entry<Integer, Integer> entry1, Entry<Integer, Integer> entry2) {
				return ((Integer)entry2.getValue()).compareTo((Integer)entry1.getValue());
				}
			});
	    
		int res[] = new int[n];
		int hoge = 0, hogehoge = 0;
	    for(int i = 0; i < n; i++){
	    	if(hoge != entries.get(i).getValue()){
	    		hoge = entries.get(i).getValue();
	    		hogehoge = i + 1;
	    		res[entries.get(i).getKey() - 1] = hogehoge;
	    	}else{
	    		res[entries.get(i).getKey() - 1] = hogehoge;
	    	}
	    }
	    
	    for(int var : res) System.out.println(var);
	}
}

Measured memory_bytes: 38456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> H(n); rep(i, n) cin >> H[i];
  ll ans = 0;
  ll tmp = 0;
  rep(i, n-1) {
    if(H[i+1] > H[i]) {
      chmax(ans, tmp);
      tmp = 0;
    } else {
      tmp++;
    }
  }
  chmax(ans, tmp);
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3992
# -*- coding: utf-8 -*-


#----------
W,H,N = list(map(int, input().rstrip().split()))
x_y_a = [list(map(int, input().rstrip().split())) for _ in range(N)]
#----------
x_max,y_max = W,H
x_min,y_min = 0,0

for x,y,a in x_y_a:
    if a == 1 and x_min < x:
        x_min = x
    elif a == 2 and x_max > x:
        x_max = x
    elif a == 3 and y_min < y:
        y_min = y
    elif a == 4 and y_max > y:
        y_max = y
    
if (x_max >= x_min) and (y_max >= y_min):
    area = (x_max - x_min) * (y_max - y_min)
else:
    area = 0

print(area)


Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
    int w , n , i , tem = 0 ;
    int ab[30][2] = {{0}};
    int num[30] = {0};

    scanf("%d%d",&w,&n);

    for(i = 0 ; i < w ; i++){
        num[i] = i + 1 ;
    }

    for(i = 0 ; i < n ; i++){
        scanf("%d,%d",&ab[i][0],&ab[i][1]);
        tem = num[ab[i][0]-1];
        num[ab[i][0]-1] = num[ab[i][1]-1] ;
        num[ab[i][1]-1] = tem ;
    }
    for(i = 0 ; i < w ; i++){
        printf("%d\n",num[i]);
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
const int N = 123456;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    int a[n + 1];
    rep(i , 1 , n) cin >> a[i];

    sort(a + 1 , a + n + 1);

    int sum = 0;

    rep(i , 1 , n - 1) sum += a[i];

    sum += a[n] / 2;
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long a, b, c, x, y, e = 0;
	cin >> a >> b >> c >> x >> y;
	if (a + b > c + c) {
		e += c * 2 * min(x, y);
	}
	else {
		e += (a + b) * min(x, y);
	}
	if (x > y) {
		e += min((x - y)*a, (x - y) * 2 * c);
	}
	else {
		e += min((y - x)*b, (y - x) * 2 * c);
	}
	cout << e << endl;
	cin >> e;
}

Measured memory_bytes: 256
#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;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,j,k,in) for(int i=(j); i < (k);i+=in)
#define FORD(i,j,k,in) for(int i=(j); i >=(k);i-=in)
#define REP(i,b) FOR(i,0,b,1)
#define REPD(i,b) FORD(i,b,0,1)
#define pb push_back 
#define mp make_pair
#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.1415926535 

int main(){
 	ios_base::sync_with_stdio(false);
 	cin.tie(NULL); cout.tie(NULL);
 	int n,m; cin >> m >> n;
 	ll sum = 0;
 	REP(i,n){
 	 	int a; cin >> a;
 	 	sum+=a;
 	}
 	if(sum > m) cout << -1 << endl;
 	else cout << m-sum << endl;
 	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>

using namespace std;

int check(string &inp)
{
    int ret = 0, tmp = 0;
    bool flag = false;

    inp += '.';
    
    for (int i = 0; i < inp.size(); i++) {
        if (isdigit(inp[i])) {
            if (flag) {
                tmp *= 10;
                tmp += inp[i] - '0';
            }
            else {
                tmp = inp[i] - '0';
                flag = true;
            }
        }
        else if (flag) {
            ret += tmp;
            flag = false;
        }
    }
    return ret;
}

int main()
{
    int ans = 0;
    string inp;

    while (cin >> inp) 
        ans += check(inp);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1184
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	list<int>ms_p;
	ms_p.push_back(6);
	for (int i = 1; i * 7 + 1 <= 300000; i++) {
		bool flag = true;
		for (auto j : ms_p) {
			if ((i*7+1)%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag) {
			ms_p.push_back(i * 7 + 1);
		}
		flag = true;
		for (auto j : ms_p) {
			if ((i * 7 + 6) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag) {
			ms_p.push_back(i * 7 + 6);
		}
	}
	cin >> N;
	while (N>1) {
		cout << N << ":";
		for (auto i : ms_p) {
			if (N%i == 0) {
				cout << " " << i;
			}
		}
		cout << endl;
		cin >> N;
	}
	return 0;
}

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

using namespace std;
int main()
{
  int start,end;
  string s1,s2;
  while(1){
    
    cin>>s1;
    if(s1==".") return 0;
    cin>>s2;
    vector<string> i1(0);
    vector<string> i2(0);
    //s1
    start=0,end=-1;
    for(int i=0;i<s1.size();i++){
      if(s1[i]=='"'){
	end=max(0,i-1);
	if(end-start>0){
	  //cout<<"a:i:"<<i<<" "<<s1.substr(start,end-start+1)<<" "<<endl;
	  i1.push_back(s1.substr(start,end-start+1));
	}else{
	  //cout<<"c:i:"<<i<<endl;
	  i1.push_back("");
	}
	start=i+1; end=-1;
	//cout<<"start:"<<start<<" end:"<<end<<endl;
      }
      if((end==-1)and(i==s1.size()-1)){
	end=i;
	//cout<<"b:i:"<<i<<" "<<s1.substr(start,end-start+1)<<" "<<endl;
	i1.push_back(s1.substr(start,end-start+1));
	start=i+1; end=-1;
      }
    }
    //s2
    start=0,end=-1;
    for(int i=0;i<s2.size();i++){
      if(s2[i]=='"'){
	end=max(0,i-1);
	if(end-start>0){
	  i2.push_back(s2.substr(start,end-start+1));
	}else{
	  i2.push_back("");
	}
	start=i+1; end=-1;
      } 
      if((end==-1)and(i==s2.size()-1)){
	end=i;
	i2.push_back(s2.substr(start,end-start+1));
	start=i+1; end=-1;
      }
    }
    int count=0;
    if(i1.size()!=i2.size()){
      //cout<<"a"<<endl;
      count=2;
    }else{
      for(int i=0;i<i1.size();i++){
	if(i%2){
	  if(i1[i]!=i2[i]){
	    //cout<<"b"<<endl;
	    count++;
	  }
	}else{
	  //cout<<"c"<<endl;
	  if(i1[i]!=i2[i]){
	    count=2;
	    break;
	  }
	}
      }
    }

    if(count==0){
      cout<<"IDENTICAL"<<endl;
    }else if(count==1){
      cout<<"CLOSE"<<endl;
    }else{
      cout<<"DIFFERENT"<<endl;
    }
  }
  return 0;
}



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

int main(void){
    vector<pair<string,string>> p(4);
    p[0].first="A";
    p[1].first="T";
    p[2].first="C";
    p[3].first="G";
    p[0].second="T";
    p[1].second="A";
    p[2].second="G";
    p[3].second="C";
    string A;
    cin>>A;
    rep(0,i,4){
        if(A==p[i].first){
            cout<<p[i].second<<endl;
        }
    }
}


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

int main(){
    int N,M,i,j;

    vector<int> a(50);
    vector<int> b(50);

    cin >> N >> M;

    vector<int> count(N+1,0);

    for(i=0;i<M;i++){
        cin >> a.at(i) >> b.at(i);
        count.at(a.at(i))+=1;
        count.at(b.at(i))+=1;
    }

    for(i=1;i<=N;i++){
        cout << count.at(i) << endl;
    }
}

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

int main(){
  int x;
  cin >> x;
  int h = x / 3600;
  int m = (x / 60) % 60;
  int s = x % 60;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

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

		while(sc.hasNext()) {
			int d = sc.nextInt();
			int w = sc.nextInt();
			int h = sc.nextInt();

				if (d == 0 && w == 0 && h == 0) {
					break;
				}

			double a = Math.sqrt(Math.pow(d, 2) + Math.pow(w, 2));
			double b = Math.sqrt(Math.pow(w, 2) + Math.pow(h, 2));
			double c = Math.sqrt(Math.pow(h, 2) + Math.pow(d, 2));

			int n = sc.nextInt();


			for (int i = 0; i < n; i++) {
				int r = sc.nextInt();

				double min = a;
				min = Math.min(b, min);
				min = Math.min(c, min);


				if ( min < r * 2) {
					System.out.println("OK");
				} else {
					System.out.println("NA");
				}
			}

		}
		sc.close();
	}
}


Measured memory_bytes: 25904
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    h,w=map(int,input().split())
    aa=[list(map(int,input().split())) for _ in range(h)]
    bb=[int(input()) for _ in range(w)]
    for ak in aa:
        ans=0
        for a,b in zip(ak,bb):
            ans+=a*b
        print(ans)

main()



Measured memory_bytes: 6328
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;

unordered_map<int,int> ass;
 
void prime_factor(int n){
    for(int i=2;i*i<=n;i++){
        while(n%i==0){
            ass[i]++;;
            n/=i;
        }
    }
    if(n != 1)ass[n]++;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,p;
    cin>>n>>p;
    prime_factor(p);
    int res=1;
    for(auto it:ass)res*=pow(it.first,it.second/n);
    cout<<res<<endl;
}

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

int main() {
    int a, b, c;
    bool flg = false;
    cin >> a >> b >> c;
    if (a == b) {
        if (a != c) flg = true;
    } else if (b == c) {
        if (a != b) flg = true;
    } else if (a == c) {
        if (a != b) flg = true;
    }
    if (flg) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector<int> vi;
 
int n;
 
int f(vi a, int n, int idx)
{
	vi kesu;
 
	for (int i = idx + 1; i < n; ++i) {
		if (a[i] != a[idx]) break;
		kesu.push_back(i);
	}
	for (int i = idx - 1; i >= 0; --i) {
		if (a[i] != a[idx]) break;
		kesu.push_back(i);
	}
 
	if (kesu.size() < 3) return n;
 
	while (!kesu.empty()) {
		a[kesu.back()] = 0;
		kesu.pop_back();
	}
	a[idx] = 0;
 
	vi b;
 
	int nextidx = -1;
 
	for (int i = 0; i < n; ++i) {
		if (a[i]) {
			b.push_back(a[i]);
			if (nextidx == -1 && i >= 1 && a[i - 1] == 0) {
				nextidx = b.size() - 1;
			}
		} else {
			if (nextidx == -1) {
				if (!b.empty()) {
					nextidx = i - 1;
				}
			}
		}
	}
 
   return f(b, b.size(), nextidx); 
}
 
int calc(vi a, int n, int idx)
{
	vi b = a;
	if (idx >= 3 && a[idx - 1] == a[idx - 2] && a[idx - 2] == a[idx - 3]) {
		b[idx] = b[idx - 1];
	} else if (idx <= n - 4 && a[idx + 1] == a[idx + 2] && a[idx + 2] == a[idx + 3]) {
		b[idx] = b[idx + 1];
	} else if (idx >= 2 && idx <= n - 2 && a[idx - 1] == a[idx - 2] && a[idx - 1] == a[idx + 1]) {
		b[idx] = b[idx - 1];
	} else if (idx >= 1 && idx <= n - 3 && a[idx - 1] == a[idx + 1] && a[idx - 1] == a[idx + 2]) {
		b[idx] = b[idx - 1];
	} else {
		return n;
	}
 
	return f(b, b.size(), idx);
}
 
int main()
{
	while (scanf("%d", &n), n) {
		vi arr;
 
		for (int i = 0; i < n; ++i) {
			int a; scanf("%d", &a);
			arr.push_back(a);
		}
 
		int mi = 10001;
 
		for (int i = 0; i < n; ++i) {
			mi = min(mi, calc(arr, arr.size(), i));
		}
 
		printf("%d\n", mi);
	}
}

Measured memory_bytes: 37768
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

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

int main(){
  string s;
  cin>>s;
  if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3]))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main ()
{
	int n, a[101], i, minj, j, tmp, count;
	
	scanf ("%d", &n);
	for (i = 0; i < n; i++) {
		scanf ("%d", &a[i]);
	}
	
	count = 0;
	
	for (i = 0; i < n; i++) {
		minj = i;
		for (j = i+1; j < n; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		if (a[i] > a[minj]) {
			tmp = a[i];
			a[i] = a[minj];
			a[minj] = tmp;
			count++;
		}
	}
	
	for (i = 0; i < n; i++) {
		if(i) {
			printf (" ");
		}
		printf ("%d", a[i]);
		}
		printf ("\n%d\n", count);
	return 0;
}



Measured memory_bytes: 1992
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	int n,a=0;
	cin >> n;
	int m = n;
	while(n != 0){
		a += n%10;
		n/=10;
	}
	(m%a == 0)? cout << "Yes" << endl : cout << "No" << endl;
    return 0;
}

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

int main(void){
   int N;
   cin>>N;
   vector<long long> a(N),b(N),c(N);
   for(int i=0;i<N;i++){
      cin>>a[i]>>b[i]>>c[i];
   }
   vector<vector<long long>> dp(N,vector<long long>(3));
   for(int i=0;i<N;i++){
      for(int j=0;j<3;j++){
         dp[i][j]=0;
      }
   }
   dp[0][0]=a[0];
   dp[0][1]=b[0];
   dp[0][2]=c[0];
   for(int i=1;i<N;i++){
      dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
      dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
      dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
   }
   long long ans=0;
   for(int i=0;i<3;i++){
      ans=max(dp[N-1][i],ans);
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 11172
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  char A,B;
  cin>>A>>B;
  if(A=='H'){
    if (B=='H') {
      cout<<'H'<<endl;
    }
    else cout<<'D'<<endl;
  }
  else if(A=='D'){
    if(B=='H')cout<<'D'<<endl;
    else cout<<'H'<<endl;
  }
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, i321) => {
        read_value!($next, i32) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
use std::cmp;
fn main() {
    input! { a: usize, b: usize, c: usize }
    println!("{}", cmp::min(cmp::min(a+b, a+c), b+c));
}

Measured memory_bytes: 4352
loop {
  n = gets.chomp.to_i
  n == 0 && break

  s = gets.split.map(&:to_i)
  m = s.inject(:+).to_f / n
  a = 0

  n.times { |i|
    a += ((s[i] - m)**2) / n
  }
  puts Math.sqrt(a)
}

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


int main() {
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]){
    cout << "Yes";
  }
  else if(s[3] == s[1] && s[1] == s[2]){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  return 0;
}






Measured memory_bytes: 3580
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    double d, t, s;
    cin >> d >> t >> s;
    
    if((d/s)>t) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3684
n = int(input())
A = tuple(map(int, input().split()))

CO = [0] * 8
o32 = 0
for a in A:
    if a >= 3200:
        o32 += 1
        continue
    for i in range(8):
        if 4*i*100 <= a < 4*(i+1)*100: 
            CO[i] += 1
ans = 0
for count in CO:
    if count > 0:
        ans += 1
print(1 if ans==0 else ans, ans+o32)


Measured memory_bytes: 9056
S = input()
l = len(S)
flug = 0
if S[0] == "A":
	S = S.replace("A","a")
	if S.count("C")==1 and S.find("C") > 1 and S.find("C") < l-1:
		S = S.replace("C","c")
		if S.lower() == S:
			flug = 1

if flug == 1:
	print("AC")
else:
	print("WA")

Measured memory_bytes: 3060
import System.Environment
import Data.Maybe
import Data.List
import Control.Exception

main :: IO ()
main = do
  isTest <- getEnv "TEST" `catch` (\(SomeException _) -> return "")
  if isTest == "1"
    then do
      testFile <- readFile "tests"
      putStrLn $ tests testFile
    else do
      input <- getContents
      putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve [c1,c2,c3,_,c4,c5,c6]|c1==c6&&c2==c5&&c3==c4="YES"
                          |otherwise="NO"

tests :: String -> String
tests text = case testParse text of
  Right bodys -> unlines (fmap (\(i, body) -> test i body) (zip [1 ..] bodys))
  Left  msg   -> "Test file parse error:" ++ msg

test :: Int -> (String, String) -> String
test n (input, outputRight)
  | output == outputRight
  = header ++ "Passed"
  | otherwise
  = header
    ++ "Faild\n"
    ++ "Right:"
    ++ show outputRight
    ++ "\nOutput:"
    ++ show output
 where
  header = "test" ++ show n ++ ":"
  output = trim $ solve input

testParse :: String -> Either String [(String, String)]
testParse s = case lines s of
  (sp1:sp2:bodys) -> testBodysParse sp1 sp2 bodys
  _               -> Left "testParse"

testBodysParse
  :: String -> String -> [String] -> Either String [(String, String)]
testBodysParse sp1 sp2 = (traverse . testBodyParse) sp2 . (split sp1)

testBodyParse :: String -> [String] -> Either String (String, String)
testBodyParse sp body = case fmap (trim . unlines) (split sp body) of
  [input, output] -> Right (input, output)
  _               -> Left "testBodyParse"

split :: Eq a => a -> [a] -> [[a]]
split spratar = foldr f [[]]
 where
  f x (p:ps) | x == spratar = [] : p : ps
             | otherwise    = (x : p) : ps
  f _ _ = undefined

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 380
import java.util.*;
import java.io.*;
import java.lang.*;

class Main
{


    public static void main(String args[])throws IOException{
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

	while(true){
	    String NARIYOSHI_X = in.readLine();
	    StringBuilder val = new StringBuilder(NARIYOSHI_X);
	    if(NARIYOSHI_X.charAt(0) == '-')break;
	    int teger,deci;
	    if(val.indexOf(".") != -1){
		teger = Integer.parseInt(val.substring(0,val.indexOf(".")));
		deci = Integer.parseInt(val.substring(val.indexOf(".")+1));
	    }
	    else {
		teger = Integer.parseInt(NARIYOSHI_X);
		deci = 0;
	    }
	    //	    System.out.println("test : " + teger + " . " + deci);
	   
	    List<Boolean> list = new ArrayList<Boolean>();
	    List<Boolean> list2 = new ArrayList<Boolean>();
	    if(teger != 0){
		while(teger != 1){
		    boolean bval;
		    
		    if(list.size() > 8){
			break;
		    }
		    
		    if(teger%2 == 0)bval = false;
		    else bval = true;
		    list.add(bval);
		    teger = teger/2;
		}
		list.add(true);
	    }
	    
	    if(list.size() > 8){
		System.out.println("NA");
		continue;
	    }

	    Collections.reverse(list);

	    if(deci != 0){
		double ddec;
		String s = "0";
		s += NARIYOSHI_X.substring(NARIYOSHI_X.indexOf("."));
        
		ddec = Double.parseDouble(s);
        	
		while(ddec != 0.0){
		    if(list2.size() > 4)break;		    
		    
		    ddec*=2.0;
		    if(ddec >= 1.0){
			list2.add(true);
			ddec -= 1.0;
		    }
		    else {
			list2.add(false);
		    }
		}
		
		if(list2.size() > 4){
		    System.out.println("NA");
		    continue;
		}
		
		//Collections.reverse(list2);
		
	    }
	    
	    if(list.size() < 8){
		for(int i=0;i<8-list.size();i++){
		    System.out.print(0);
		}
	    }
	    
	    for(int i=0;i<list.size();i++){
		if(list.get(i))System.out.print(1);
		else System.out.print(0);
	    }
	    System.out.print(".");
	    for(int i=0;i<list2.size();i++){
		if(list2.get(i))System.out.print(1);
		else System.out.print(0);
	    }

	    if(list2.size() < 4){
		for(int i=0;i<4-list2.size();i++){
		    System.out.print(0);
		}
	    }

	    System.out.println("");

	}

    }

}

Measured memory_bytes: 10000
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;

const char* alice = "Alice";
const char* borys = "Borys";

int main()
{
	int n, a, b;

	scanf("%d%d%d", &n, &a, &b);

	if((b - a) % 2 == 0) {
		printf("%s\n", alice);
	} else {
		printf("%s\n", borys);
	}

	return 0;
}

/* waffle */


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

#define endl "\n"
#define pb push_back
#define MOD 1000000007LL
#define PI 3.1415926

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T> inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

signed main(void){
	cin.tie(0);
	// ios::sync_with_stdio(false);

	int n;double x;string u; cin >> n;
	double ans = 0.0;
	REP(i, n){
		cin >> x >> u;
		if(u == "JPY") ans += x;
		else ans += x*380000.0;
	}
	printf("%.6f\n", ans);

	return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const int iinf = 1 << 29;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll mrand(ll B) {
  return (ull)rng() % B;
}

int m[2][2019];

void work() {
    string s; cin>>s;
    int n = s.size();
    ll sum = 0, ans = 0;
    int cur = 0;
    m[cur][0] = 1;
    for (int i = 0; i < n; ++i) {
        int d = s[i] - '0';
        sum = (sum + d) % 2019;
        ans += m[cur][sum];
        for (int j = 0; j < 2019; ++j) m[cur^1][j] = 0;
        for (int j = 0; j < 2019; ++j) {
            m[cur^1][(j*10)%2019] += m[cur][j];
        }
        sum = (sum * 10) % 2019;
        ++m[cur^1][sum];
        cur ^= 1;
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //int nt; cin>>nt; while (nt--) work();
    work();
    return 0;
}


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

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<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    vector<ll> a(N); rep(i, N){cin >> a.at(i);}
    ll cnt = 0;
    rep(i, N){
        if (i % 2 == 0 && a.at(i) % 2 == 1){cnt++;}
    }
    cout << cnt << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  vector<ll> p(n);
  rep(i,n){
    cin>>p[i];
  }

  auto copy=p;

  sort(all(copy));

  rep(i,n){
    if(p[i]<=copy[(n/2)-1]) cout << copy[n/2] << endl;
    else if(p[i]>=copy[n/2]) cout << copy[(n/2)-1] << endl;
  }

}

Measured memory_bytes: 5376
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
#include <fstream>
#include <cassert>
#include <cmath>
#include <sstream>
#include <time.h>
#include <complex>

#include <unordered_map>
#include <unordered_set>
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define DFOR(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define rep(i,n) FOR(i,0,n)
#define repn(i,n) FORN(i,1,n)
#define drep(i,n) DFOR(i,n-1,0)
#define drepn(i,n) DFOR(i,n,1)
#define MAX(a,b) a = Max(a,b)
#define MIN(a,b) a = Min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define Reset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(all(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define forever for(;;)
#define PINF 1000000000000
#define newline '\n'

#define test if(1)if(0)cerr
using namespace std;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;
const double pi = acos(-1.0);


const int maxn = 1e5+1;
vector<int> g[maxn];
int n, m;
vector<int> path;
bool vis[maxn];
void dfs(int cur)
{
    vis[cur] = true;
    path.pb(cur);
    for (auto nxt : g[cur])
    {
        if (!vis[nxt])
        {
            dfs(nxt);
            break;
        }
    }
}
int main()
{
    cin >> n >> m;
    repn(i, m)
    {
        int u, v;   cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    repn(i, n)
    {
        vis[i] = false;
    }
    dfs(1);
    reverse(path.begin(), path.end());
    path.pop_back();
    dfs(1);
    cout << path.size() << newline;
    bool first = true;
    for (auto e : path)
    {
        if (first) first = false;
        else cout << " ";
        cout << e;
    }
    cout << newline;
    
}

Measured memory_bytes: 9720
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 110;

int n, k;
char s[N];

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

int main() {
    scanf("%s", s + 1), n = strlen(s + 1), read(k);
    if (s[1] != s[n]) {
        ll ans = 0;
        for (R int i = 2; i <= n; ++i)
            if (s[i] == s[i - 1]) s[i] = 0, ++ans;
        cout << ans * k << endl;
        return 0;
    }
    ll ans = 0;
    int l = n + 1, r = 0;
    for (R int i = 1; i <= n; ++i)
        if (s[i] != s[n]) l = min(l, i), r = max(r, i);
    if (!r) {
        cout << (ll) n * k / 2 << endl;
        return 0;
    }
    for (R int i = l + 1; i <= r; ++i)
        if (s[i] == s[i - 1]) s[i] = 0, ++ans;
    cout << ans * k + ((ll) (n - r + l - 1) / 2 * (k - 1)) + (l - 1) / 2 + (n - r) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256