akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
int main(){
	int n, a, b;
	int ans = 0;
	cin >> n >> a >> b;

	for (int i = 0; i <= n; i++) {
		int m;
		m = i % 10 + (i / 10) % 10 + (i / 100) % 10 + (i / 1000) % 10+(i/10000)%10;

		if (m <= b && m >= a)ans+=i;

	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N=200000+10;
const int INF=10000000;
int p1[N],p2[N];
map<pair<int,int>,int>m;
int find(int x,int *p) {
	return p[x]==x?p[x]:p[x]=find(p[x],p);
}
void cha(int x,int y,int *p) {
	int px=find(x,p);
	int py=find(y,p);
	if(px!=py) {
		p[px]=py;
	}
}
int main() {
	int n,k,l;
	cin>>n>>k>>l;
	for(int i=1; i<=n; i++)
		p1[i]=i,p2[i]=i;
	for(int i=1; i<=k; i++) {
		int x,y;
		scanf("%d%d,",&x,&y);
		cha(x,y,p1);
	}
	for(int i=1; i<=l; i++) {
		int x,y;
		scanf("%d%d,",&x,&y);
		cha(x,y,p2);
	}
	for(int i=1; i<=n; i++) {
		find(i,p1);
		find(i,p2);
	}
	for(int i=1; i<=n; i++)
		m[make_pair(p1[i],p2[i])]++;
	for(int i=1; i<=n; i++)
		printf("%d ",m[make_pair(p1[i],p2[i])]);
	return 0;
}

Measured memory_bytes: 13568
#include<iostream>

using namespace std;

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

	for (int i = 1; i <= n; i++)
	{
		int x = i;

		if (x % 3 == 0)
			cout << " " << i;
		else
		{
			while (x > 0)
			{
				if (x % 10 == 3)
				{
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;

}

Measured memory_bytes: 3096
n = int(input())
A = [1]+[pow(6,i) for i in range(1,7)]+[pow(9,i) for i in range(1,6)]
D = [0]+[-1]*n
for i in range(1,n+1):
    D[i] = D[i-1]+1
    for j in range(1,7):
        if pow(6,j)>i: break
        D[i] = min(D[i], D[i-pow(6,j)]+1)
    for j in range(1,6):
        if pow(9,j)>i: break
        D[i] = min(D[i], D[i-pow(9,j)]+1)
print(D[-1])

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    set<int> s;
    s.insert(A);
    s.insert(B);
    s.insert(C);
    if (s.size() == 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n,m;cin>>n>>m;
    string s;cin>>s;
    reverse(all(s));
    ll cnt=0;
    bool f=1;
    rep(i,n){
        if(s[i]=='0')cnt=0;
        else cnt++;
        if(cnt==m)f=0;
    }
    if(!f){
        cout<<-1<<endl;
        return 0;
    }
    ll last=0;
    vector<ll>ans(0);
    ll k=0;
    cnt=0;
    rep(i,n+1){
        if(s[i]=='0'){
            k=i;
        }
        if(i-last==m||i==n){
            ans.pb(k-last);
            last=k;
        }
    }
    reverse(all(ans));
    rep(i,ans.size()){
        if(ans[i]==0)continue;
        cout<<ans[i]<<' ';
    }
    cout<<endl;
}

Measured memory_bytes: 1528
#include<stdio.h>
int main (void){
int a,b,i,z;
while(scanf("%d %d",&a,&b) != EOF){
        z = a+b;
        i = 0;
    for(;;){
        if(z<1) break;
        z = z/10;
        i++;
    }
    printf("%d\n",i);
}
return 0;
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll diff = b - a;
  if (diff%2) {
    cout << (diff-1)/2 + (n-a < b-1 ? n-b+1 : a) << endl;
  }
  else {
    cout << diff / 2 << endl;
  }
}


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

struct Problem {

	void Solve() {
		UL N, M; cin >> N >> M;
		vector<vector<UL>> E(N);
		vector<UL> F(N);
		vector<UL> P(N, -1);
		rep(i, N + M - 1) {
			UL u, v; cin >> u >> v; u--; v--;
			E[u].push_back(v);
			F[v]++;
		}
		queue<UL> Q; rep(i, N) if (F[i] == 0) Q.push(i);
		while (Q.size()) {
			UL p = Q.front(); Q.pop();
			for (UL e : E[p]) {
				F[e]--;
				if (F[e] == 0) {
					P[e] = p;
					Q.push(e);
				}
			}
		}
		rep(i, N) cout << (P[i] + 1) << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 7040
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

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

int main(){
    int N;
    cin>>N;
    int d[N];
    rep(i,N) cin>>d[i];
    int sum=0;
    rep(i,N-1){
        for(int j=i+1;j<N;j++){
            sum+=d[i]*d[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1e9 + 7;

int main(void)
{
    string S, T, U;
    int A, B;

    cin >> S >> T >> A >> B >> U;

    if (S == U)
    {
        A--;
    }
    else if (T == U)
    {
        B--;
    }

    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<time.h>
#include<cstdlib>
typedef long long ll;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mm(a) memset(a,0,sizeof(a))
#define lr rt<<1
#define rr rt<<1|1
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0);
#define inf 0x3f3f3f3f
//#define eqs 1e-8
#define lb(x) (x&(-x))
#define ch(a) (int(a-'0'))
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef pair<int,int> pii;
const double pi=acos(-1);
const int maxn=200010;
//const ll Mod=1000000007;
const ll Mod=998244353;
using namespace std;




string s;

int main()
{
    sync;
    ll x;
    cin>>x;
    ll s=0;
    s=s+1ll*1000*(x/500);
    x%=500;
    s=s+1ll*(x/5)*5;
    cout<<s<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
//g++ -Wshadow -Wall -o A.cpp a -g -fsanitize=address -fsanitize=undefined 
#include <bits/stdc++.h>

#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define TC int tc; cin >> tc; while(tc--)

using namespace std;

const int INF = 1e9 + 7;
const int MxN = 1010;
const int MOD = 1e9 + 7;

ll h, w, dp[MxN][MxN];
char grid[MxN][MxN];

void add(ll &a, ll b){
	a = (a+b)%MOD;
	return;
}

int main(void)
{
	FAST
	cin >> h >> w;
	memset(dp, 0, sizeof dp);
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> grid[i][j];
		}
	}

	dp[0][0] = 1;
	for(int i = 1; i < h; i++)
		if(grid[i][0] == '.' && grid[i-1][0] == '.') add(dp[i][0], dp[i-1][0]);

	for(int j = 1; j < w; j++)
		if(grid[0][j] == '.' && grid[0][j-1] == '.') add(dp[0][j],dp[0][j-1]);

	for(int i = 1; i < h; i++){
		for(int j = 1; j < w; j++){
			if(grid[i][j] == '.'){
				if(grid[i-1][j] == '.') add(dp[i][j], dp[i-1][j]);
				if(grid[i][j-1] == '.') add(dp[i][j], dp[i][j-1]);
			}
		}
	}

	/*
	for(int i = 0;  i < h; i++){
		for(int j = 0; j < w; j++)
			cout << dp[i][j] << ' ';
		cout << '\n';
	}
	*/

	cout << dp[h-1][w-1] << '\n';

	return 0;
}


Measured memory_bytes: 12556
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b < c + d) {
		cout << "Right" << endl;
	}
	else if (a + b == c + d) {
		cout << "Balanced" << endl;
	}
	else {
		cout << "Left" << endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 9223372036854775807
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

const int NMAX = 100000;
ll dist[NMAX];
Graph nodes[NMAX];
bool visited[NMAX];
void dfs(ll N){
  REP(i,nodes[N].size()){
    if(visited[nodes[N][i].first]) continue;
    dist[nodes[N][i].first] = dist[N] + nodes[N][i].second;
    visited[nodes[N][i].first] = true;
    dfs(nodes[N][i].first);
  }
}

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

  int n;
  cin >> n;

  REP(_,n-1){
    int a,b,c;
    cin >> a >> b >> c;
    nodes[a-1].push_back({b-1,c});
    nodes[b-1].push_back({a-1,c});
  }
  
  ll q,k;
  cin >> q >> k;
  
  REP(i,n) dist[i] = INF;
  REP(i,n) visited[i] = false;
  dist[k-1] = 0;
  visited[k-1] = true;
  dfs(k-1);
  
  REP(_,q){
    int x,y;
    cin >> x >> y;
    cout << dist[x-1]+dist[y-1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 14464
object Main extends App {

  def isOk(cx: Seq[Char]): Boolean = {
    if (cx.length == 0) true
    else cx.map(_ == cx.head).reduce(_ && _)
  }

  def count(cx: Seq[Char], c: Char): Int = {
    @annotation.tailrec
    def loop(n: Int, _cx: Seq[Char]): Int = {
      if (isOk(_cx)) n
      else {
        val __cx = (0 until _cx.length - 1).map(i =>
          if (_cx(i) == c || _cx(i+1) == c) c
          else _cx(i)
        ).toSeq
            
        loop(n + 1, __cx)
      }
    }
    loop(0, cx)
  }

  def solve(cx: Seq[Char]): Int = 
    ('a' to 'z').map(c => count(cx, c)).reduce(_ min _)

  val sc = new java.util.Scanner(System.in)
  val str = sc.next
    
  System.out println solve(str.toList)
}

Measured memory_bytes: 30968
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf("%lld", &(n))
#define scd(n) scanf("%Ld", &(n))
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> pll;

int main(void)
{
	string s; cin >> s;
	LL ans = 0;
	LL lastw = 0;
	for (LL i = 0; i < s.length(); i++) {
		if (s[i] == 'W') {
			ans += abs(lastw - i);
			lastw++;
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	int n;
	scanf("%d",&n);
	int answer[n];
	int a[n];
	int b[n];
	int c[n];
	int i,j;
	for (i=0;i<n;i++){
		answer[i]=0;
	}
	
	for (i=0;i<n;i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}
	
	int x=0;
	int y=0;
	int z=0;
	for (i=0;i<n;i++){
		for(j=0;j<n;j++){
			if (a[i]==a[j]){
				x++;
			}
			if (b[i]==b[j]){
				y++;
			}
			if (c[i]==c[j]){
				z++;
			}
		}
		if (x==1){
			answer[i]=answer[i]+a[i];
		}
		if(y==1){
			answer[i]=answer[i]+b[i];
		}
		if (z==1){
			answer[i]=answer[i]+c[i];
		}
		x=0;
		y=0;
		z=0;
	}	
		
	for (i=0;i<n;i++){
		printf("%d\n",answer[i]);
	}
	
	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<vector<ll>> dp(n,vector<ll>(3));
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i) >> b.at(i) >> c.at(i);
    }
    dp.at(0).at(0) = a.at(0);
    dp.at(0).at(1) = b.at(0);
    dp.at(0).at(2) = c.at(0);
    for(i = 1;i < n;++i){
        dp.at(i).at(0) = max(dp.at(i-1).at(1) + a.at(i), dp.at(i-1).at(2) + a.at(i));
        dp.at(i).at(1) = max(dp.at(i-1).at(0) + b.at(i), dp.at(i-1).at(2) + b.at(i));
        dp.at(i).at(2) = max(dp.at(i-1).at(0) + c.at(i), dp.at(i-1).at(1) + c.at(i));
    }
    ll ans = 0;
    for(i = 0;i < 3;++i){
        ans = max(ans, dp.at(n-1).at(i));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8064
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[] S = sc.next().toCharArray();
        
        PriorityQueue<Integer> pq = new PriorityQueue<Integer>(Comparator.reverseOrder());
        for (int i=0;i<S.length-1;i++){
          char[] SS = new char[S.length-i];
          for (int j=0;j<S.length-i;j++){
            SS[j] = S[j+i];
          }
          pq.add(Zalgo(SS));
        }
        System.out.println(pq.poll());
    }
    public static int Zalgo(char[] S){
        int N = S.length;
        int[] A = new int[N];
        A[0] = N;
        int i = 1;
        int j = 0;
        while(i<N){
            while(i+j < N && S[j] == S[i+j]){
                j++;
            }
            A[i] = j;
            if(j==0){
                i++;
                continue;
            }
            int k = 1;
            while(i+k<N&& k  + A[k] < j){
                A[i+k] = A[k];
                k++;
            }
            i += k;
            j -= k;
        }
        PriorityQueue<Integer> pq = new PriorityQueue<Integer>(Comparator.reverseOrder());
        for (int l=0;l<N;l++){
            if(A[l]<=l){
              pq.add(A[l]);
            }
        }
        return pq.poll();
    }
    //char[] →　Character[]
    public static Character[] LIBctoC(char[] c){
        int size = c.length;
        Character[] C = new Character[size];
        for (int i = 0;i<size;i++){
            C[i] = Character.valueOf(c[i]);
        }
        return C;
    }
}

Measured memory_bytes: 137156
#include<iostream>
#include<vector>
#include<string.h>


using namespace std;

int main()
{
    char s[1001];
    char s1[1001];

    char op[10];

    cin>>s;

    int n;

    cin>>n;

    int a,b;
    while(n--)
    {
        cin>>op>>a>>b;

        if(op[0]=='p')
        {
            for(int i=a;i<=b;i++)
            {
                cout<<s[i];
            }
            cout<<endl;
        }else if(strcmp(op,"reverse")==0)
        {
            for(int i=a;i<=(a+b)/2;i++)
            {
                char ch;
                ch=s[i];
                s[i]=s[b-(i-a)];
                s[b-(i-a)]=ch;
            }
        }else
        {
            cin>>s1;
            for(int i=0;i<strlen(s1);i++)
            {
                s[a+i]=s1[i];
            }
        }
    }


    return 0;
}



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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  string ret = "";
  for (int i = 0; i < n; i++) ret += s[i], ret += t[i];
  cout << ret << '\n';
  return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin >> s >> t;
	cout << t << s << endl;	
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++)  cin >> A.at(i);
  vector<int> B(N);
  for(int i=0;i<N;i++)  cin >> B.at(i);

  vector<long long> AB(N);
  for(int i=0;i<N;i++)  AB.at(i)=A.at(i)-B.at(i);
  sort(AB.begin(),AB.end());
  long long sum=0;
  for(int i=0;i<N;i++)  sum+=AB.at(i);
  if(sum<0){
    cout << -1 << endl;
    return 0;
  }

  int ans=0;
  sum=0;
  for(int i=0;i<N;i++){
    if(AB.at(i)>=0) break;
    sum+=AB.at(i);
    ans++;
  }
  for(int i=N-1;i>=0;i--){
    if(sum>=0)  break;
    sum+=AB.at(i);
    ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<set> 
#include<vector>
#include<stack>
#include<string>
#include<ctype.h>
#include<sstream> 
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<cstring> 
using namespace std; 
int flag;
int a[11];

void dfs(int x, int l, int r)
{
	if(x == 10) return;
	if(flag) return;
	if(a[x] > l) dfs(x+1, a[x], r);
	else if(a[x] > r) dfs(x+1, l, a[x]);
	else {
		flag = 1;
		return;
	}
 } 

int main()
{	
	int n;
	cin>>n;
	while(n--)
	{
		flag = 0;
		for(int i = 0; i < 10; i++){
			cin>>a[i];
		}
		dfs(0,0,0);
		if(flag) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
	return 0;
 } 
 


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

int N;
int used;

int f(int ret,vector<string>&v){
	if(isdigit(v[used][v[used].size()-1])){
		return v[used][v[used].size()-1] - '0';
	}
	int sz = v[used].size();
	int kigou = v[used][v[used].size()-1] == '*';
	int RETURN = kigou;
	while(used+1<N&&v[used+1].size() == sz + 1){
		used++;
		if(kigou)RETURN *= f(kigou,v);
		else RETURN += f(kigou,v);
	}
	return RETURN;
}

signed main(){
	vector<int>ans;
	while(cin>>N,N){
		vector<string>v;
		REP(i,N){
			string s;
			cin >> s;
			v.push_back(s);
		}
		used = 0;
		ans.push_back(f(0,v));
	}
	for(auto e:ans)cout<<e<<endl;
}


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

int main() {
  int N;
  cin >> N;
  double ans = 0;
  for (int i = 0; i < N; i++) {
  	double d;
    string s;
    cin >> d >> s;
    ans += (s == "BTC" ? d * 380000.0 : d);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint n, k;
llint a[2005];

int main(void)
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint x = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i >= j) continue;
			if(a[i] > a[j]) x++;
		}
	}
	llint ans = x * k % mod;
	
	llint y = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(a[i] > a[j]) y++;
		}
	}
	ans += k*(k-1)/2%mod * y%mod, ans %= mod;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=(1<<60)
for i in range(n-k+1):
  if 0<a[i]:
    if a[i+k-1]<ans:
      ans=a[i+k-1]
  elif a[i+k-1]<0:
    if -a[i]<ans:
      ans=-a[i]
  else:
    if a[i+k-1]-a[i]*2<ans:
      ans=a[i+k-1]-a[i]*2
    if a[i+k-1]*2-a[i]<ans:
      ans=a[i+k-1]*2-a[i]
print(ans)

Measured memory_bytes: 14780
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	long long int a,n;
	cin >> n;
	n=n+1;
	while(n > 9){
		n = n /10;
		a=a+9;
    }
	a=a+n-1;
		cout << a << endl;
   }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int f[26];
char s[123];
char ans[123][123];

bool ok=true;
char getch(int dx){
  int at=-1;
  for(int ch=0;ch<26;ch++)if(f[ch]>=dx){
    at=ch;
    if(f[ch]%4==2)break;
  }
  if(at>=0)f[at]-=dx;
  else ok=false;
  return at+'a';
}
int main(){
  int n,m;
  scanf("%d %d",&n,&m);
  for(int i=0;i<n;i++){
    scanf("%s",s);
    for(int j=0;j<m;j++)f[s[j]-'a']++,ans[i][j]='.';
  }
  if(n%2==1 && m%2==1){
    for(int i=0;i<26;i++)if(f[i]%2==1){
      f[i]--;
      ans[n/2][m/2]=i+'a';
      break;
    }
  }
  /*
     int x=0,y=0;
     for(int i=0;i<26;i++){
     if(f[i]%4==2){
     if(n%2==1 && x<n/2){
     ans[x][m/2]=ans[n-1-x][m/2]=i+'a';
     f[i]--;
     }
     else if(m%2==1 && y<m/2){
     ans[n/2][y]=ans[n/2][m-1-y]=i+'a';
     f[i]--;
     }
     }
     }
     */
  if(n%2==1){
    for(int x=0;x<m/2;x++)ans[n/2][x]=ans[n/2][m-1-x]=getch(2);
  }
  if(m%2==1){
    for(int y=0;y<n/2;y++)ans[y][m/2]=ans[n-1-y][m/2]=getch(2);
  }
  for(int i=0;i<n/2;i++)
    for(int j=0;j<m/2;j++)
      ans[i][j]=ans[n-1-i][j]=ans[i][m-1-j]=ans[n-1-i][m-1-j]=getch(4);

  if(!ok)puts("No");
  else{
    puts("Yes");
/*
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++)putchar(ans[i][j]);
      puts("");
    }
  */
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		//int n=sc.I;
		int[] s=sc.Ia;
		Console.WriteLine("{0}",(s[1]+s[0]*3)>>1);
	}
}

public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public string Sz{get{return Console.ReadLine();}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2(int b){return Array.ConvertAll((((b&1)!=0?"0 ":"")+Console.ReadLine()+((b&2)!=0?" 0":"")).Split(),int.Parse);}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public string[] Sa2{get{return ("# "+Console.ReadLine()).Split();}}
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    vi A(Q), cnt(N, 0);
    vector<bool> res(N, 1);
    for(int i=0; i<Q; i++){
        cin >> A[i];
        A[i]--;
        cnt[A[i]]++;
    }
    for(int i=0; i<N; i++){
        if(K-(Q-cnt[i]) <= 0) res[i]=0;
    }
    for(int i=0; i<N; i++){
        cout << (res[i] ? "Yes":"No") << endl;
    }
    return 0;
}

Measured memory_bytes: 4036
H,W,M = map(int,input().split())
HW = [list(map(int, input().split())) for i in range(M)]
x = [0]*W
y = [0]*H
used = set()
for h,w in HW:
    h -= 1
    w -= 1
    y[h] += 1
    x[w] += 1
    used.add((h,w))

y_max = max(y)
x_max = max(x)
y_can = []
x_can = []
for i in range(H):
    if y[i] == y_max:
        y_can.append(i)
for i in range(W):
    if x[i] == x_max:
        x_can.append(i)

#候補地は爆弾があるり被りがあることを想定して-1しておく
ans = y_max+x_max-1
#print(ans, y_can,x_can)
flag = False
for yy in y_can:
    for xx in x_can:
        #print((yy,xx) in used,(yy,xx) ,used)
        if (yy,xx) in used:
            continue
        else:
            #候補地に爆弾がないことが確認できたので+1してループ抜け
            ans += 1
            flag = True
            break
    if flag:
        break
print(ans)
 

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

typedef long long lli;
typedef pair<lli,lli> pll;
typedef vector<lli> vcL;

void solve() {
	int n = 3;
	cin >> n;
	int s[ n+5 ], t[ n+5 ], ans = 0;
	for (int i = 0; i < n; ++i) cin >> s[i];
	for (int i = 0; i < n; ++i) cin >> t[i];
	
	for (int i = 0; i < n; ++i) {
		if ( s[i] > t[i] ) ans += s[i]-t[i];
	}
	
	cout << ans << '\n';
}

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

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

signed main()
{
    int N; cin>>N;
    
    int odd=0;
    REP(i,N){
        int a; cin>>a;
        if(a%2==1) odd++;
    }
    
    if(odd%2==0)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    
}


Measured memory_bytes: 256
[H,W,K] = list(map(int,input().split()))

s = []
for i in range(H):
    s.append(list(input()))
# print('s:',s)

##１行に何個いちごあるか
ichigo=[]
nai=[]  #苺がない行
flg=0
for i in range(H):
    dammy=0
    for j in range(W):
        if s[i][j] =='#':
            if flg==0:
                X = i
                flg=1
            dammy += 1
    if dammy==0:
        nai.append(i)
    ichigo.append(dammy)
# print('ihigo,nai:',ichigo,nai)

out = [[0]*W for i in range(H)] #2次元配列はこう準備(値わたし)、[[0
cnt=0
lim=0
for i in range(H):
    if i in nai:
        continue
    else:
        cnt+=1
        lim+=ichigo[i]
        for j in range(W):
            out[i][j]=cnt
            if s[i][j] =='#' and cnt!=lim:
                cnt+=1
            # print('lim,cnt:',lim,cnt)


for i in nai:
    if i<X:
        out[i] = out[X]
    else:
        # if i==0:
        #     out[0] = out[1]
        # else:
        out[i] = out[i-1]

for i in range(H):
    print(*out[i])

Measured memory_bytes: 78620
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    i64 ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            ans += i;
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3620
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;


namespace abc100_d
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();

            double[] w1 = new double[input[0]];
            double[] w2 = new double[input[0]];
            double[] w3 = new double[input[0]];
            double[] w4 = new double[input[0]];
            double[] w5 = new double[input[0]];
            double[] w6 = new double[input[0]];
            double[] w7 = new double[input[0]];
            double[] w8 = new double[input[0]];

            for(int i=0; i<input[0]; i++){
                double[] a = ReadLine().Split().Select(double.Parse).ToArray();
                w1[i] =  a[0] + a[1] + a[2];
                w2[i] =  a[0] + a[1] - a[2];
                w3[i] =  a[0] - a[1] + a[2];
                w4[i] = -a[0] + a[1] + a[2];
                w5[i] =  a[0] - a[1] - a[2];
                w6[i] = -a[0] - a[1] + a[2];
                w7[i] = -a[0] + a[1] - a[2];
                w8[i] = -a[0] - a[1] - a[2];
            }

            Array.Sort(w1); Array.Reverse(w1);
            Array.Sort(w2); Array.Reverse(w2);
            Array.Sort(w3); Array.Reverse(w3);
            Array.Sort(w4); Array.Reverse(w4);
            Array.Sort(w5); Array.Reverse(w5);
            Array.Sort(w6); Array.Reverse(w6);
            Array.Sort(w7); Array.Reverse(w7);
            Array.Sort(w8); Array.Reverse(w8);

            double[] count = new double[8];
            for(int i=0; i<input[1]; i++){
                count[0] += w1[i];
                count[1] += w2[i];
                count[2] += w3[i];
                count[3] += w4[i];
                count[4] += w5[i];
                count[5] += w6[i];
                count[6] += w7[i];
                count[7] += w8[i];
            }

            double max=count[0];
            for(int i=1; i<8; i++){
                max = Max(max, count[i]);
            }

            WriteLine(max);
        }

        static void Swap<T>(ref T lhs, ref T rhs)
        {
            T temp;
            temp = lhs;
            lhs = rhs;
            rhs = temp;
        }
    }
}

Measured memory_bytes: 13580
s = list(input())
count = 0
check = 0
tem = str()

for i in range(0,len(s)):
    if check == 2:
        check = 1
        count += 1
        continue
    if check == 1:
        check = 0

    if tem == "" or tem != s[i]:
        count += 1
        tem = s[i]
    else:
        check = 2
        tem = str()
print(count)

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

class UnionFind {
public:
    vector<LL> parent;
    vector<LL> member;

    int root(LL x) {
        if(x == parent[x]) {
            return x;
        }
        return parent[x] = root(parent[x]);
    }

    UnionFind(LL N) {
        parent.resize(N);
        for(int i = 0;i < N;i++) {
            parent[i] = i;
        }
        member.resize(N, 1);
    }

    bool same(LL x, LL y) {
        return root(x) == root(y);
    }

    LL size(LL x) {
        return member[root(x)];
    }

    void unite(LL x, LL y) {
        if(same(x, y)) {
            return;
        }
        member[root(y)] += member[root(x)];
        parent[root(x)] = root(y);
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N + 1);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        uf.unite(a, b);
    }

    set<int> leader;
    int k = -1;
    FOR(i, 1, N + 1) {
        int team = uf.size(i);
        k = max(k, team);
    }
    cout << k << endl;
    return 0;
}


Measured memory_bytes: 12612
import sys
input = sys.stdin.buffer.readline

N = int(input())
A = list(map(int, input().split()))

def gcd(x, y):
  while y:
    x, y = y, x % y
  return x

answer = A[0]
for i in range(1, N):
  answer = gcd(A[i], answer)
  
print(answer)

Measured memory_bytes: 12492
import sys

readline = sys.stdin.readline


def main():
    N, X, M = map(int, readline().split())

    P = N.bit_length()
    pos = [[0] * M for _ in range(P)]
    value = [[0] * M for _ in range(P)]

    for r in range(M):
        pos[0][r] = r * r % M
        value[0][r] = r

    for p in range(P - 1):
        for r in range(M):
            pos[p + 1][r] = pos[p][pos[p][r]]
            value[p + 1][r] = value[p][r] + value[p][pos[p][r]]

    ans = 0
    cur = X
    for p in range(P):
        if N & (1 << p):
            ans += value[p][cur]
            cur = pos[p][cur]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 118204
A, B, C = map(int, input().split())
total = A*B*C
if A >= B and A >= C:
    x = A
    y = B
    z = C
elif B >= A and B >= C:
    x = B
    y = A
    z = C
else:
    x = C
    y = A
    z = B
if x % 2 == 0:
    ans = 0
else:
    ans = x % 2*y*z
print(ans)


Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define LL long long
#define PI pair<int,int>
#define PL pair<LL,LL>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;

int a,b;

int main(){
    cin >> a >> b;
    int ans = 0;
    int x = 1;
    while(x < b){
        ans++;
        x--;
        x += a;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>

#define FOR(i,m,n) for (int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define DEBUG(a) printf("%d\n", a)

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

  int tmp_train;
  //// all train
  tmp_train = N * A;

  int min = MIN(tmp_train, B);

  DEBUG(min);

  return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n,m,k;cin >>n>>m>>k;
    vector<int>a(n);
    vector<int>b(m);
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >>b[i];
    }
    ll ans=0;
    vector<ll>suma(n+1,0);
    for (int i = 0; i < n; ++i) {
        suma[i+1]=suma[i]+a[i];
    }
    vector<ll>sumb(m+1,0);
    for (int i = 0; i < m; ++i) {
        sumb[i+1]=sumb[i]+b[i];
    }
//    for (int i = 0; i < m + 1; ++i) {
//        cout <<sumb[i]<<" ";
//    }
//    cout <<endl;
    for (int i = 0; i <=n; ++i) {
        if(suma[i]>k)continue;
        ll now=i;
        ll c=k;
        c-=suma[i];
        if(sumb[m]<=c){
            now+=m;
        }
        else {
            auto it = upper_bound(all(sumb), c) - sumb.begin();
            if (it != 0) {
                now += it - 1;
            }
        }
//        cout <<i<<" "<<c<<" "<<it<<endl;
//        cout <<now<<endl;
        ans=max(ans,now);
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 8012
import sys

input = sys.stdin.readline
R, C, K = map(int, input().split())
values = [[0]*C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, input().split())
    values[r-1][c-1] = v

dp = [[[0 for _ in range(C+1)] for _ in range(R+1)] for _ in range(4)]

for r in range(R-1, -1, -1):
    # dp[0][r][C - 1] = dp[3][r + 1][C - 1]
    # for i in range(1, 4):
    #    dp[i][r][C-1] = dp[3][r + 1][C-1][3]+values[r][C-1]
    for c in range(C-1, -1, -1):
        v = values[r][c]
        for i in range(4):
            if i == 0 or v == 0:
                dp[i][r][c] = max(dp[3][r+1][c], dp[i][r][c+1])
            else:
                dp[i][r][c] = max(dp[3][r + 1][c]+v, dp[i][r][c + 1], dp[i-1][r][c + 1] + v)

print(dp[3][0][0])


Measured memory_bytes: 454144
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long

using namespace std;


int main(void){
  ll start,move,num;
  cin >> start >> num >> move;
  ll moved = floor(start / move);
  ll ans;
  if(moved > 0){
    if(moved > num){
      ans = start - num * move;
      cout << ans << endl;
      return 0;
    }else{
      start = start - moved * move;
      num = num - moved;
    }
  }else{
    moved = -moved;
    if(moved > num){
      ans = start + num*move;
      cout << -ans << endl;
      return 0;
    }else{
      start = start + moved*move;
      num = num - moved;
    }
  }
  num = num % 2;
  if(num == 1){
    if(start > 0){
      ans = start - move;
    }else{
      ans = start + move;
    }
  }else{

    ans = start;
  }
  if(ans < 0){
    ans = -ans;
  }
  cout << ans << endl;
  
  return 0;
}

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

int main() {
  int N, M;
  map<string, int> mp;

  cin >> N;
  rep(i, N) {
    string s;
    cin >> s;
    mp[s]++;
  }
  cin >> M;
  rep(i, M) {
    string s;
    cin >> s;
    mp[s]--;
  }

  string res_s;
  int res_num = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->second > res_num) {
      res_s = itr->first;
      res_num = itr->second;
    }
  }

  cout << res_num << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
typedef long long ll;
cs int Mod = 998244353;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b){ return a - b < 0 ? a - b + Mod : a - b; }
int mul(int a, int b){ return 1ll * a * b % Mod; }
void Add(int &a, int b){ a = add(a, b); }
void Dec(int &a, int b){ a = dec(a, b); }
void Mul(int &a, int b){ a = mul(a, b); }
int ksm(int a, int b){ int as=1; for(;b;b>>=1,Mul(a,a)) if(b&1) Mul(as,a); return as; }
cs int N = 3e6 + 50;
int fc[N], ifc[N], n, m;
void fc_init(int n){
	fc[0] = fc[1] = ifc[0] = ifc[1] = 1;
	for(int i=2; i<=n; i++) fc[i] = mul(fc[i-1], i);
	ifc[n] = ksm(fc[n], Mod-2);
	for(int i=n-1; i>=2; i--) ifc[i] = mul(ifc[i+1], i+1);
}
int C(int n, int m){
	if(n < 0 || m < 0 || n < m) return 0;
	return mul(fc[n], mul(ifc[n-m], ifc[m]));
}
int coef(int c, int z){
	int ans = C(z + n - 1, n - 1);
	Dec(ans, mul(n, C(z - m - 1 + n - 1, n - 1)));
	Mul(ans, C(n, c));
	int t = (m - c) >> 1;
	if(t < 0 || !c) return ans;
	int dc = C(t + n - 2, n - 2);
	Mul(dc, C(n - 1, c - 1));
	return dec(ans, mul(n, dc));
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d%d",&n,&m);
	fc_init(m * 3 + n);
	int Ans = C(m * 3 + n - 1, n - 1);
	Dec(Ans, mul(n, C(m + n - 2, n - 1)));
	int ans = 0;
	for(int i = 0; i <= n; i++){
		if((3 * m - i) & 1) continue;
		int ct = (3 * m - i) >> 1;
		if(i <= ct) Add(ans, coef(i, ct));
	} cout << ans;
	return 0;
}

Measured memory_bytes: 23268
#include<iostream>
#include <vector>
#include <math.h>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((b - 1) / a < c / a) cout << "OK" << endl; else cout << "NG" << endl;
}


Measured memory_bytes: 3104
#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 a; cin >> a;
    cout << a + a * a + a * a * a << endl;
}

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



Measured memory_bytes: 3644
(let* ((n (read))
    (a (make-array n))
    (money 1000)
    (kabu 0)
    (upFlg Nil)
    (tmpA 0))
    (loop for i below n do
        (setf (aref a i) (read))
    )
    (loop for i below n do
        (if (= i 0)
            (setq tmpA (aref a i))
            (if (not (= tmpA (aref a i)))
                ;;保存した価格よりi日目の株価が上がった
                (if (< tmpA (aref a i))
                    ;;保存した価格が最安値の場合は保存した価格で買う
                    (if (eq upFlg Nil)
                        (progn
                            (setq upFlg T)
                            (incf kabu (floor (/ money tmpA)))
                            (decf money (* (floor (/ money tmpA)) tmpA))
                            (setq tmpA (aref a i))
                        )
                        ;;株価が連続して上昇したなら株価を保存するだけ
                        (setq tmpA (aref a i))
                    )
                    ;;保存した日より株価が下がった
                    ;;連続して下がった
                    (if (eq upFlg Nil)
                        (setq tmpA (aref a i))
                        ;;保存した日が最高値なら保存した価格で買う
                        (progn
                            (setq upFlg Nil)
                            (incf money (* kabu tmpA))
                            (setq kabu 0)
                            (setq tmpA (aref a i))
                        )
                    )

                )
            )
        )
        (if (= i (- n 1))
            (incf money (* kabu tmpA))
        )
    )
    (princ money)
)

Measured memory_bytes: 24540
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

template<typename T1,typename T2>
std::ostream& operator<< (std::ostream& os,std::pair<T1,T2> pa){return os<<"["<<pa.first<<", "<<pa.second<<"]";}

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

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

// UnionFind
template<class T>
class UnionFind {
  private:
  std::vector<T> uni;
  T num;

  public:
  UnionFind(T s) : uni(s, -1), num(s) {}

  //頂点aが所属するグループ
  T root(T a) {
    if (uni[a] < 0) {
      return a;
    }
    return uni[a] = root(uni[a]);
  }

  // a,bをつなげる
  bool connect(T a, T b) {
    a = root(a);
    b = root(b);
    if (a == b) {
      return false;
    }

    if (uni[a] > uni[b]) {
      std::swap(a, b);
    }

    uni[a] += uni[b];
    uni[b] = a;
    return true;
  }

  // a,bが同グループか確認
  bool isConnect(T a, T b) { return root(a) == root(b); }

  // aが属するグループの要素数
  T size(T a) { return -uni[root(a)]; }

  //グループ数を返す
  T groups() {
    std::set<T> b;
    for (T i = 0; i < num; i++) {
      b.insert(root(i));
    }
    return b.size();
  }
};

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,k;
  std::cin>>n>>k;

  std::vector<ll> a(n);
  rep(i,0,n)std::cin>>a[i];

  UnionFind<ll> ans(n-k+1);

  ll prv=a[0],cnt=1,temp=-1;

  rep(i,1,n){
    if(a[i]>prv){
      cnt++;
    }else{
      cnt=1;
    }
    prv=a[i];
    if(cnt>=k){
      if(temp!=-1)ans.connect(temp,i-k+1);
      temp=i-k+1;
    }
  }

  std::set<ll> set;

  rep(i,0,k)set.insert(a[i]);

  rep(i,1,n-k+1){
    ll min=*set.begin();
    set.erase(a[i-1]);set.insert(a[k+i-1]);
    ll max=*set.rbegin();
    if(min==a[i-1]&&max==a[k+i-1]&&(!ans.isConnect(i,i-1)))ans.connect(i,i-1);
  }

  std::cout<<ans.groups();

  return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
const int INF = 100000;
typedef pair<int, int> P;
int n;
int main()
{
    string s, t;
    while (1)
    {
        vector<int> a, b;
        cin >> s >> t;
        if (s == ".")
            return 0;
        if (s == t)
        {
            cout << "IDENTICAL" << endl;
        }
        else
        {
            a.push_back(0);
            b.push_back(0);
            for (int i = 0; i < s.size(); i++)
            {
                if (s[i] == '"')
                {
                    a.push_back(i);
                }
            }
            for (int i = 0; i < t.size(); i++)
            {
                if (t[i] == '"')
                {
                    b.push_back(i);
                }
            }
            if (a.size() != b.size())
            {
                cout << "DIFFERENT" << endl;
            }
            else
            {
                int cnt = 0;
                for (int i = 1; i < a.size() - 1; i += 2)
                {
                    int x = a[i + 1] - a[i] + 1;
                    int y = b[i + 1] - b[i] + 1;
                    if (s.substr(a[i], x) != t.substr(b[i], y))
                    {
                        cnt++;
                    }
                }
                string u;
                if (cnt == 1)
                {
                    u = "CLOSE";
                }
                cnt = 0;
                a.push_back(s.size() - 1);
                b.push_back(t.size() - 1);
                for (int i = 0; i < a.size() - 1; i++)
                {
                    int x = a[i + 1] - a[i] + 1;
                    int y = b[i + 1] - b[i] + 1;
                    if (s.substr(a[i], x) != t.substr(b[i], y))
                    {
                        cnt++;
                    }
                }
                if (cnt >= 2)
                {
                    u = "DIFFERENT";
                }
                if (u == "")
                    u ="DIFFERENT";
                cout << u << endl;
            }
        }
    }
}


Measured memory_bytes: 3132
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>

using namespace std;

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

	int n;
	string w[110];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		if (i != 0) {
			int l = w[i - 1].length();
			if (w[i][0] != w[i - 1][l - 1]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (w[i] == w[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static long solve(long x, long k, long d) {
		x = Math.abs(x);
		long q = x / d;
		long r = x % d;
		if (q >= k)
			return x - d * k;
		long remaining = k - q;
		if (remaining % 2 == 0)
			return r;
		else
			return d - r;
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long x, k, d;

		x = stdIn.nextLong();
		k = stdIn.nextLong();
		d = stdIn.nextLong();
		System.out.println(solve(x, k, d));

		stdIn.close();
	}
}


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


int main(){
  int N, K;
  string S;

  cin>>N>>S>>K;

  for(int i = 0; i < S.size(); i++) cout<<(S[i]==S[K-1]?S[i]:'*');
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 256