akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll A, B;
    cin >> A >> B;
    cout << max(max(A+B, A-B), A*B) << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

#define uint unsigned int
#define int long long
#define ull unsigned long long
#define ld long double
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;
using namespace std;
const int N = 1e5 + 10;
int n , L ;
int a[N] , range1 = -1 , range2;

main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n >> L;
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i];
	}
	for(int i = 2 ; i <= n ; i++){
		if(a[i] + a[i - 1] >= L){
			range1 = i - 2;
			range2 = i;
			break;
		}
	}
	if(range1 + range2 > 0){
		cout << "Possible\n";
		for(int i = 1 ; i <= range1 ; i++)
			cout << i << '\n';
		for(int i = n - 1 ; i >= range2 ; i--)
			cout << i << '\n';
		cout << range2 - 1;
	}
	else 
		puts("Impossible");
}

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

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

    int continueCount = 0;

    bool isYes = false;

    for (int i = 0; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;

        if (a == b)
        {
            ++continueCount;

            if (continueCount == 3)
            {
                isYes = true;
            }
        }
        else
        {
            continueCount = 0;
        }
    }

    cout << (isYes ? "Yes" : "No") << endl;
}

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

#define M 1e9+7
#define ll long long int
#define vii vector<int>
#define pii pair<int,int>

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

    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];

    int dp[n]={0};

    for(int i=1;i<n;i++){
        int op1=abs(a[i]-a[i-1])+dp[i-1];
        int op2=i>=2?abs(a[i]-a[i-2])+dp[i-2]:INT_MAX;
        dp[i]=min(op1,op2);
    }

    cout<<dp[n-1]<<endl;



    return 0;
}

Measured memory_bytes: 1024
S=str(input())

ans = 0
if S == "SSS":
	ans = 0
elif S == "SSR" or S == "RSS" or S == "RSR" or S == "SRS":
	ans = 1
elif S == "SRR" or S == "RRS":
	ans = 2
elif S == "RRR":
	ans = 3
print(ans)

Measured memory_bytes: 9032
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static int mi = 196470;
    public static long res;
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int y = sc.nextInt();
            int m = sc.nextInt();
            int d = sc.nextInt();
            res = 0;
            int ty = (y+1)%3;
            int tty = (y-1)/3;
            res += tty * 590;
            if (ty%3==0) {
                res += 195;
                res += calc(m);
                res += d;
            } else if (ty%3==1) {
                res += 390;
                res += (m-1)*20;
                res += d;
            } else if (ty%3==2) {
                res += calc(m);
                res += d;
            }
            System.out.println(mi - res + 1);
        }
    }
    
    public static int calc(int m) {
        int res = 0;
        for (int i = 1; i < m; i++) {
            if (i%2==0) {
                res += 19;
            } else {
                res += 20;
            }
        }
        return res;
    }
}

Measured memory_bytes: 26748
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,i,j,r=0,b=0;
	cin>>n;
	string s;
	cin>>s;
	for(i=0;i<n;i++)
		if(s[i]=='R')r++;
		else b++;
	if(r>b)cout<<"Yes";else cout<<"No";
	return 0;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	
	vi a(n) , b(n) , c(n);
	rep(i , n)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	
	vector<vi> dp(n , vi(3));
	dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
	
	repi(i , n - 1)
	{
		dp[i][0] = max(dp[i - 1][1] , dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0] , dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][0] , dp[i - 1][1]) + c[i];
	}
	
	cout << max(dp[n - 1][0] , max(dp[n - 1][1] , dp[n - 1][2]));

	return 0;
}

Measured memory_bytes: 6912
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  string str;
  int flag[3],cnt=0;
  for(int i=0;i<3;i++)flag[i]=0;
  cin>>str;
  for(int i=0;i<3;i++){
  	if(str[i]=='a')flag[0]=1;
  	else if(str[i]=='b')flag[1]=1;
  	else if(str[i]=='c')flag[2]=1;
  }
  for(int i=0;i<3;i++){
  	if(flag[i]==1)cnt++;
  }
  if(cnt==3)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int N;
  
  while(cin >> N && N) {
    int mx = 0;
    int mid;
    for(int i=0; i<N; i++) {
      int id; cin >> id;
      int a, b; cin >> a >> b;
      if(mx < a+b) {
	mx = a+b;
	mid = id;
      }
    }
    cout << mid << " " << mx << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
static const int MAX =100;
static const int INFTY =(1<<21);
static const int WHITE =0;
static const int GRAY =1;
static const int BLACK =2;

int n, M[MAX][MAX];

int dijkstra(){
  int minv;
  int d[MAX],color[MAX];

  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }
  d[0]=0;
  color[0]=GRAY;
  while(1){
    minv=INFTY;
    int u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i] && color[i] !=BLACK){
        u=i;
        minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v] != BLACK && M[u][v]!=INFTY){
        if(d[v]> d[u]+M[u][v]){
          d[v]=d[u]+M[u][v];
          color[v]=GRAY;
        }
      }
    }
  }
  for(int i=0;i<n;i++){
    cout << i << " " << (d[i]==INFTY? -1:d[i]) << endl;
  }
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }
  int k,c,u,v;
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int j=0;j<k;j++){
      cin >> v >> c;
      M[u][v]=c;
    }
  }

  dijkstra();
  return 0;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool isExist[26];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    string T = S;
    if (S.length() == 26) {
        next_permutation(S.begin(), S.end());
        //cout << S << endl;
        string K = S;
        while(true) {
            K.pop_back();
            if (K > T) S = K;
            else break;
        }
        if (S < T) cout << -1 << endl;
        else cout << S << endl;
        return 0;
    }
    rep(i, S.length()) {
        isExist[S[i] - 'a'] = true;
    }
    rep(i, 26) {
        if (!isExist[i]) {
            cout << S << (char)('a' + i) << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <cctype>
#include <cmath>
using namespace std;

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	outl((int) abs((int) in - (int) in));
}


Measured memory_bytes: 2616
function main() {
  function howMuch(gram) {
    var
    i, j, w, g, c, p,
    min, _pat,
    pat = [[0,[]]];
    for(i = 0; i < 3; i++) {
      w = [200,300,500][i];
      _pat = [];
      while(p = pat.shift()) {
        g = p[0];
        c = p[1];
        for(j = 0; j*w+g <= gram; j++) {
          _pat.push([j*w+g,c.concat(j)]);
        }
        _pat.push([j*w+g,c.concat(j)]);
      }
      pat = _pat;
//      console.log(pat);
    }
    pat = _pat;
//    console.log(pat);
    min = Infinity;
    while(p = pat.shift()) {
      g = p[0];
      if(g !== gram) continue;
      c = p[1];
      p = ((c[0]%5)*380)+(~~(c[0]/5)*5*(380*0.8 ))
         +((c[1]%4)*550)+(~~(c[1]/4)*4*(550*0.85))
         +((c[2]%3)*850)+(~~(c[2]/3)*3*(850*0.88));
      min = p<min?p:min;
    }
    return min;
  }
  
  var
  end = false;
  input.forEach(function(line) {
    if(line.trim() == '' || end) return;
    if(line == 0){
      end = true;
      return;
    }
    console.log(howMuch(parseInt(line, 10)));
  });
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

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

int cnt;
vector<vector<int>> G(3e5);
vector<int> seen(3e5,false);

void dfs(int u) {
  seen[u]=true;
  cnt++;
  for(int next:G[u]) if(seen[next]==false) dfs(next);
}

int main() {
  int n,m; cin>>n>>m;
  int a,b,ans=0;
  for(int i=0;i<m;i++) {
    cin>>a>>b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(int i=1;i<=n;i++) {
    if(seen[i]==false) {
      cnt=0;
      dfs(i);
    }
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 23720
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            int[] ds = DisjointSets.createSets(n + m);
            for (int i = 0; i < n; i++) {
                int k = in.nextInt();
                int first = in.nextInt() - 1;
                for (int j = 1; j < k; j++) {
                    DisjointSets.unite(ds, first, in.nextInt() - 1);
                }
                DisjointSets.unite(ds, first, i + m);
            }
            HashSet<Integer> roots = new HashSet<>();
            for (int i = 0; i < n; i++) {
                roots.add(DisjointSets.root(ds, i + m));
            }

            out.println(roots.size() > 1 ? "NO" : "YES");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class DisjointSets {
        public static int[] createSets(int size) {
            int[] p = new int[size];
            for (int i = 0; i < size; i++)
                p[i] = i;
            return p;
        }

        public static int root(int[] p, int x) {
            return x == p[x] ? x : (p[x] = root(p, p[x]));
        }

        public static boolean unite(int[] p, int a, int b) {
            a = root(p, a);
            b = root(p, b);
            if (a != b) {
                p[a] = b;
                return true;
            }
            return false;
        }

    }
}



Measured memory_bytes: 34640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

vector<int> to[N];
ll ans=1;
const int MAX = 1000000;
const int MOD = 1000000007;

void dfs(int no,int p,int k){
	if(-1==p){
		for(int i=k-1;i>=k-SZ(to[no]);i--){
			ans*=i;
			ans%=MOD;
			//OUT(ans);
		}
	}else{
		for(int i=k-2;i>=k-SZ(to[no]);i--){
			ans*=i;
			ans%=MOD;
		}
	}
	for(auto &s:to[no]){
		if(s==p) continue;
		
		//OUT(ans);
		dfs(s,no,k);
	}
}
int main(){
	int n,k;
	cin>>n>>k;
	REP(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	int m=0;
	REP(i,n){
		m=max(m,SZ(to[i]));
	}
	
		dfs(0,-1,k);
		ans*=k;
		ans%=MOD;
		OUT(ans);
	return 0;
}

Measured memory_bytes: 9216
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
#include<climits>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<(n);i++)
#define INF INT_MAX;
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){
    
    int dp[100010];
    dp[0]=0;
	int i,n,power;
	cin>>n;
	for(i=1;i<=100000;i++){
		power=1;
		dp[i]=INF;
		while(power<=i){
//			cout<<i<<" "<<dp[i]<<" "<<dp[i-power]+1<<endl;
			dp[i]=min(dp[i],dp[i-power]+1);
			power*=6;
		}
		power=1;
		while(power<=i){
			dp[i]=min(dp[i],dp[i-power]+1);
			power*=9;
		}
	}
//	for(i=1;i<=127;i++)cout<<dp[i]<<endl;
	cout<<dp[n]<<endl;
	return 0;
}


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

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int r;
    cin >> r;
    cout << 3 * r * r;
    return 0;
}

Measured memory_bytes: 256
N,T =map(int,input().split())
min_N=1000
min_T=1000
for  i in range (N):
    N_,T_ =map(int,input().split())
    if T_<=T:
        min_T=T_
        if N_<min_N:
            min_N=N_
            
if min_T>T:
    print ('TLE')
else:
    print (min_N)

Measured memory_bytes: 3060
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}


int main(){
    LL h1,w1;
    cin>>h1>>w1;
    LL h2=w1,w2=h1;
    LL ans=INF;

    LL s1,s2,s3;
    for(int i=0;i<=w1;++i){
        s1=h1*i;
        s2=h1*((w1-i)/2);
        s3=h1*w1-(s1+s2);
        ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)));
        
        s1=h1*i;
        s2=(w1-i)*(h1/2);
        s3=h1*w1-(s1+s2);
        ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)));

    }

    for(int i=0;i<=w2;++i){
        s1=h2*i;
        s2=h2*((w2-i)/2);
        s3=h2*w2-(s1+s2);
        ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)));
        
        s1=h2*i;
        s2=(w2-i)*(h2/2);
        s3=h2*w2-(s1+s2);
        ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)));
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define F 		first
#define S 		second
#define ll 		long long
#define ld 		long double
#define pii		pair<int, int>
#define vi 		vector<int>
#define mii 	map<int, int>
#define umii 	unordered_map<int, int>
#define pb		push_back
#define mk		make_pair
#define ask(x) 	cerr << #x << " = " << x << "\n";
#define INF 	1000000007
#define hell 	998244353

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int a, b, c, k;

	cin >> a >> b >> c >> k;

	int res = min(a, k) * 1;
	k -= min(a, k);
	res += min(b, k) * 0;
	k -= min(b, k);
	res += min(c, k) * -1;
	k -= min(c, k);
	cout << res;

	return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int op(int a, int b) {return max(a,b);}

int e() {return -1;}

int target;
bool f(int v) {return v < target;}

int main(){
    int n,q; cin >> n >> q;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    segtree<int, op, e> seg(a);

    rep(_, q){
        int t; cin >> t;
        if(t == 1){
            int x,v; cin >> x >> v; x--;
            seg.set(x, v);
        }
        else if(t == 2){
            int l,r; cin >> l >> r; l--;
            cout << seg.prod(l,r) << endl;
        }
        else if(t == 3){
            int p; cin >> p >> target; p--;
            cout << seg.max_right<f>(p)+1 << endl;
        }
    }
}


Measured memory_bytes: 6144
n = gets.to_i
l = gets.chomp.split.map(&:to_i).sort!

res = 0
0.step(n - 3) do |i|
  (i + 1).step(n - 2) do |j|
    if l[i] == l[j]
      next
    end
    (j + 1).step(n - 1) do |k|
      if l[j] == l[k]
        next
      end
      if l[k] < l[i] + l[j]
        res += 1
      end
    end
  end
end
puts res

Measured memory_bytes: 14320
#include <iostream>
using namespace std;
int main(void)
{
    int A = 0, B = 0;
    cin >> A >> B;

    int kosu = 0;
    
    if (B == 1)
    {
        kosu = 0;
    }
    else if (A >= B)
    {
        kosu++;
    }
    else
    {
        kosu ++;
        int S = A-1;
        int G = A;
        do
        {
            G += S;
            kosu++;
            //cout << kosu << " " << endl;
        } while (G < B);
        
        
    }
    cout << kosu <<endl;
    
    

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const int maxn=50+10;
struct node{
    LL v,c;
    LL cha;
}p[maxn];
int n;
bool cmp(node x,node y){
    return x.cha>y.cha;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>p[i].v;
    for(int i=1;i<=n;i++) cin>>p[i].c;
    for(int i=1;i<=n;i++) p[i].cha=p[i].v-p[i].c;
    sort(p+1,p+1+n,cmp);
    int sum=0;
    for(int i=1;i<=n;i++){
        if(p[i].cha>=0) sum+=p[i].cha;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
#s = input()
#S = []
#for i in range(N):
S = input().split(" ")
for i in range(N):
    S[i] = float(S[i])
S.sort()
for i in range(N-1):
    S[i+1] = (float(S[i])+float(S[i+1])) / 2.000000
print(S[N-1])




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

typedef long long ll;

int n, k;
int a[105];
int game[200005];
bool vis[200005];

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

    int minval = 1<<30;
    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    sort(a, a+n);

    for(int i = 0; i < a[0]; i++) {
        game[i] = 0;
    }

    for(int i = a[0]; i <= k; i++) {
        bool willwin = 0;
        for(int j = 0; j < n && i >= a[j]; j++) {
            if(game[i-a[j]] == 0) {
                willwin = 1;
                break;
            }
        }
        game[i] = willwin;
    }

    if(game[k] == 1) {
        printf("First\n");
    } else {
        printf("Second\n");
    }

    return 0;
}


Measured memory_bytes: 640
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]

l = sorted(l, key = lambda x:(x[1], x[0]))
cnt = 0
con_l = 0

for i in range(m):
    if con_l <= l[i][0]:
        cnt += 1
        con_l = l[i][1]

print(cnt)


Measured memory_bytes: 35852
use text_io::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;

fn main() {
    let n:String = read!();
    let v:Vec<char> = n.chars().collect();
    if v[0]==v[1] || v[1] == v[2] || v[2] == v[3] {
        println!("Bad");
    }
    else {
        println!("Good");
    }
}

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

int main(){
    char a, b;
    cin >> a >> b;
    if(a == 'H' && b == 'H')cout << "H" << endl;
    else if(a == 'D' && b == 'H')cout << "D" << endl;
    else if(a == 'D' && b == 'D')cout << "H" << endl;
    else if(a == 'H' && b == 'D')cout << "D" << endl;
}

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

#define pb push_back
#define REP(i,a) for(long i=0;i<(a);++i)

typedef std::vector< int > VI;
typedef std::vector< VI > VI2;

int N, M;
VI2 path;
int main() {
    std::cin >> N >> M;
    path.resize(N);

    REP(i, M) {
        int a, b;
        std::cin >> a >> b;
        a--, b--;
        path[a].pb(b);
        path[b].pb(a);
    }

    for(auto pl: path) {
        std::cout << pl.size() << std::endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int N,M,A[101]={},B[101][101]={};
  int i,j;
  int ans[101]={};
  cin >> N >> M;
  for(i=0;i<M;++i){
    cin >> A[i];
  }
  for(i=0;i<M;++i){
    for(j=0;j<N;++j){
      cin >> B[i][j];
      if(B[i][j]==A[i]) {
	ans[j]++;
      }
      else {
	ans[A[i]-1]++;
      }
    }
  }
  for(i=0;i<N;++i)
    cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 3124
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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 main(void) {
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B >= C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <utility>
#include <queue>
#include <vector>
using namespace std;
#define M 10010
long long int Min(long long int x,long long int y){
        return x>y?x:y;
}
int main(){
        int N;
        cin >> N;
        vector <pair<int,int> >adjancent[M];
        for(int i=0 ; i<N ; i++ ){
                int node,degree,to,cost;
                cin >> node >> degree;
                for(int l=0;l<degree;l++){
                        cin >> to >> cost;
                        adjancent[node].push_back(make_pair(to,cost));
                }
        }
        priority_queue<pair<long long int,long long int> > descending;
        descending.push(make_pair(0,0));
        vector<long long int> dp(N,2400000000);
        dp[0]=0;
        while(descending.size()!=0){
                pair<long long int,long long int> now=descending.top();descending.pop();
                for(int i=0;i<adjancent[now.first].size();i++){
                        pair<long long int,long long int>next=adjancent[now.first][i];
                        if(dp[next.first]>dp[now.first]+next.second){
                                dp[next.first]=dp[now.first]+next.second;
                                descending.push(make_pair(next.first,dp[next.first]));
                        }
                }
        }
        for(int i=0 ; i<N ; i++ )
                cout<<i<<" "<<dp[i]<<endl;
        return 0;
}


Measured memory_bytes: 8108
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <stack>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF INT_MAX>>1 //要climits#includ
#define SIZE 100001;
#define MOD 2019
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

typedef long long ll;

using namespace std;

int main(void){
	int L, R; cin >> L >> R;
	R = min(R, L+4038);
	ll ans = INF;
	for(ll i=L; i<=R; i++){
		for(ll j=i+1; j<=R; j++){
			ans = min(ans, i*j%MOD);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
interface Tree{
    fun intersection(other:Tree):Tree
    fun union(other:Tree):Tree
    companion object {
        fun parse(str:String):Tree {
            val (tree, _) = parse(str, 0)
            return tree
        }
        private fun parse(str:String, left:Int):Pair<Tree, Int> {
            return when{
                str[left] == '(' -> {
                    val (leftNode, pos) = parse(str, left + 1)
                    val (rightNode, pos2) = parse(str, pos + 1)
                    Pair(Node(leftNode, rightNode), pos2 + 1)
                }
                else -> Pair(Leaf, left)
            }
        }
    }
}
object Leaf : Tree{
    override fun union(other: Tree): Tree {
        return other
    }

    override fun intersection(other:Tree): Tree {
        return this
    }

    override fun toString(): String {
        return ""
    }
}
class Node constructor(private var leftNode:Tree = Leaf, private var rightNode:Tree= Leaf): Tree {
    override fun intersection(other: Tree): Tree {
        return when(other){
            is Node -> Node(leftNode.intersection(other.leftNode), rightNode.intersection(other.rightNode))
            else -> Leaf
        }
    }

    override fun union(other: Tree): Tree {
        return when(other){
            is Node -> Node(leftNode.union(other.leftNode), rightNode.union(other.rightNode))
            else -> this
        }
    }

    override fun toString(): String {
        return "($leftNode,$rightNode)"
    }
}

fun main(args:Array<String>):Unit {
    var str:String? = readLine()
    while (str != null){
        val (order, a, b) = str.split(' ')
        println(when(order){
            "i" -> Tree.parse(a).intersection(Tree.parse(b))
            else -> Tree.parse(a).union(Tree.parse(b))
        })
        str = readLine()
    }
}


Measured memory_bytes: 30972
N = int(input())
input = [int(s) for s in input().split()]
ans = 0
temp=sum(input)
for i in range(N-1):
    temp=temp-input[i]
    ans = (ans + (input[i]*((temp)%(10**9+7)))%(10**9+7))%(10**9+7)
print(ans)

Measured memory_bytes: 31584
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int n, a, b, c;
	cin >> n;
	while(cin >> a >> b >> c){
		if(b < c)
			swap(b, c);
		if(a < b)
			swap(a, b);
		if(b < c)
			swap(b, c);
		if(pow(a, 2) == pow(b, 2)+pow(c, 2))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    ll K;
    cin >> S >> K;
    int a = 0;
    int s = S.size();
    REP(i, s)
    {
        if (S.at(i) != '1')
            break;
        a++;
    }

    if (a >= K)
        cout << "1" << endl;
    else
        cout << S.at(a) << endl;
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
map<char,int> 
count_same_elements(const vector<char>& v){map<char,int>cmap; for_each(v.begin(),v.end(),[&cmap](int x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T,class U>
void msg_with_compare(T A,T B,U A_greater_B,U A_eq_B,U A_less_B){
    if(A==B){cout<<A_eq_B<<"\n";}else if(A>B){cout<<A_greater_B<<"\n";}else{cout<<A_less_B<<"\n";}}
template<class B,class T>
void msg_with_boolean(B A,T true_msg,T false_msg){cout<< ( A? true_msg:false_msg);}
template<class B,class T>
void msg_with_boolean(B A1,B A2,T both_true_msg,T true_false_msg,T false_true_msg,T both_false_msg){
    if(A1){if(A2){cout<<both_true_msg;}else{cout<<true_false_msg;}
    }else{if(A2){cout<<false_true_msg;}else{cout<<both_false_msg;}}
}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}

ll n,x;
vector<ll> m;
void input(){
    cin>>n;
}
void src(){
    string s=to_string(n);
    ll sum=0;
    for(auto i:s){sum+=(i-'0');}
    msg_with_boolean(n%sum==0,"Yes","No");
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define INF 100000000000ULL

using namespace std;

namespace Kyopro {

    using ll = long long;



    const ll MOD = 998244353LL;

    const int MAX = 210000;

    long long fac[MAX], finv[MAX], inv[MAX];

    // テーブルを作る前処理
    void COMinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    // 二項係数計算
    long long COM(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    long long modpow(long long a, long long n, long long mod) {
        long long res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    ll f(size_t m, size_t n) {
        ll ret = (m * modpow(m - 1, n - 1, MOD)) % MOD;
        return ret;
    }

    long long modinv(long long a, long long m) {
        long long b = m, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    ll combinations2(size_t n, size_t k) {
        ll r = 1;
        for (ll d = 1; d <= k; ++d) {
            r *= n--;
            r = r % MOD;
            r = r * modinv(d, MOD);
            r = r % MOD;
        }
        if (r > MOD / 2) {
            r -= MOD;
        }
        return r;
    }
}

using namespace Kyopro;

const double PI = acos(-1);

void solve() {
    size_t a, b, h, m;
    cin >> a >> b >> h >> m;
    double t1 = 2.0 * PI * (h + m / 60.0) / 12.0;
    double t2 = 2.0 * PI * m / 60.0;
    double t = t2 - t1;
    double af = a;
    double bf = b;
    double ret = sqrt(a * a + b * b - 2.0 * a * b * cos(t));
    cout << std::fixed << std::setprecision(20) << ret << endl;
}

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

    COMinit();

    solve();

    return 0;
}

Measured memory_bytes: 9128
import scala.collection.mutable.ListBuffer

object Main extends App {
  import scala.io.StdIn.readLine

  val hw = readLine().split(" ").map(_.toInt)
  val h = hw(0)
  val w = hw(1)

  var list: ListBuffer[String] = new ListBuffer[String]
  for (i <- 1 to h) {
    val line = readLine()
    if (line.contains("#")) list += line
  }

  var blist: ListBuffer[Boolean] = new ListBuffer[Boolean]
  for (j <- 0 to w - 1) {
    var flag = false
    list.foreach(x => {
      if (!x(j).equals('.')) flag = true
    })
    blist += flag
  }

  for (i <- 0 to list.size - 1) {
    for (j <- 0 to w - 1) {
      if (blist(j)) print(list(i)(j))
    }
    if (i != list.size - 1) println()
  }
}


Measured memory_bytes: 29116
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
class Prime{
public:
    vector<bool>Isprime;
    vector<int>prime;
    int size;
    Prime(int n) : Isprime(n+1,true),size(n+1){
        Isprime[0] = Isprime[1] = false;
        for(int i = 2; i<=size; i++){
            if(!Isprime[i])continue;
            prime.push_back(i);
            for(int j = 2;i*j <=size;j++) Isprime[i*j] = false;
        }
    }
    bool IsPrime(int n){return (n<=size? Isprime[n]:false);}
    int indexOf(int i){return (i<prime.size()?prime[i]:INF);}
};
signed main(){
    Prime p(123456*5);
    int n;
    while(cin >> n, n){
        int cnt = 0;
        for(int i = 0; i< p.prime.size();i++)
            if(n+1 <= p.prime[i] && p.prime[i] <=2*n)cnt++;
        cout << cnt << endl;
    }
}




Measured memory_bytes: 3412
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int c,sum=0;
    for(int i=1;i<=N;i++){
        if(i%2==0){continue;}
        c=0;
        for(int j=1;j<=i;j++){
            if (i%j==0){c++;}
        }
        if(c==8){sum++;}
    }
    cout<<sum<<endl;
}

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

using namespace std;

int main(){

  	int x, y=1;
  	int maximum, minimum;
   
  	while(x>0 || y >0){
  		cin >> x >> y;
        
        if(x==0 && y==0) break;
      
      	maximum = max(x,y);
      	minimum = min(x,y);
      	cout << minimum << " " << maximum << endl;
     }
    return 0;
}


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

int main(){
	map< string , vector<int> > index;
	int page;
	string s;

	while( cin >> s >> page ){
		index[s].push_back( page );
	}
	
	map< string , vector<int> >::iterator it;
	for( it = index.begin() ; it != index.end() ; ++it ){
		sort( it->second.begin() , it->second.end() );
		
		cout << it->first << endl;
		for(int i=0 ; i < it->second.size() ; ++i ){
			cout << it->second[i];
			( i == it->second.size()-1 )? cout << endl : cout << " " ;
		}
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
char tb[128];
int main() {
	int n,m;
	while(scanf("%d",&n),n) {
		memset(tb,0,sizeof(tb));
		for(int i=0;i<n;i++) {
			getchar();
			char ch1=getchar(),ch2=(getchar(),getchar());
			tb[ch1]=ch2;
		}
		scanf("%d",&m);
		for(int i=0;i<m;i++) {
			getchar();
			char ch=getchar();
			if(tb[ch]==0) putchar(ch);
			else putchar(tb[ch]);
		}
		putchar('\n');
	}
}

Measured memory_bytes: 1000
N,K=map(int,input().split())
S=input()
count=0
total=0

for i in range(N-1):
    if S[i]==S[i+1]:
        total+=1
    else:
        count+=1
if K*2>=count:
    print(total+count)
else:
    print(total+K*2)

Measured memory_bytes: 3316
// https://atcoder.jp/contests/abc175/tasks/abc175_c
#include <iostream>
#include <vector>
#include <deque>
#include <tuple>
#include <algorithm>
#include <iterator> // std::back_inserter
#include <climits>
#include <sstream>

using namespace std;

typedef unsigned long ll;

ll n;

int main()
{
    cin >> n;
    cout << (1000-(n % 1000))%1000 << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#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 REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  double ave = 1.0 * accumulate(all(A), 0LL) / N;
  int ans = 0;
  double mn = inf;
  rep(i, N) {
    if(abs(A[i]-ave) < mn) {
      mn = abs(A[i]-ave);
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int INF = 0x3f3f3f3f;
const int N = 5000;
#define ll long long
int cmp(int a,int b){
	return a>b;
}	

int main(){
	int  n;
	cin >> n;
	ll s=0;
	for(int i=1;i<=n;i++){
		if(i%3 && i%5){
			s += i;
		}
	}
	cout << s<<endl;
	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int imp(){
	cout << "Impossible" << endl;
	return 0;
}

int main(){
	int n; cin >> n;
	vector<int> a(n);
	for( auto &k : a ) cin >> k;
	int d = *max_element(a.begin(), a.end());
	vector<int> g(n+1);
	fill_n(g.begin(), n+1, 0);
	for( auto k : a ) ++g[k];
	for( int k = d; k >= 1; --k ){
		if( k > (d+1)/2 && g[k] < 2 ){
			// cout << "case 0: g[k] = " << g[k] << endl;
			return imp();
		}
		if( k == (d+1)/2 ){
			if( d % 2 == 0 && g[k] != 1 ){
				// cout << "case 1: g[k] = " << g[k]  << endl;
				return imp(); 
			} else if( d % 2 == 1 && g[k] != 2 ){
				// cout << "case 2: g[k] = " << g[k] << endl;
				return imp();
			}
		}
		if( k < (d+1)/2 && g[k] > 0 ){
			// cout << "case 3: g[k] = " << g[k] << ", " << k << endl;
			return imp();
		}
	}
	cout << "Possible" << endl;
	return 0;
}

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

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

const long long INF = 1LL << 60;
const int MAX_INDEX = 100010;
long long dp[MAX_INDEX][3];

int main()
{
  int N; 
  std::cin >> N;
  long long a[MAX_INDEX][3];
  for ( int i = 0; i < MAX_INDEX; i++ ) {
    for ( int j = 0; j < 3; j++ ) {
      std::cin >> a[i][j];
    }
  }
  for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j < 3; j++ ) {
      for ( int k = 0; k < 3; k++ ) {
        std::cin >> N;
        if ( j == k ) continue;
        chmax(dp[i+1][k], dp[i][j] + a[i][k]);
      }
    }
  }
  long long res = 0;
  for ( int i = 0; i < 3; i++ ) {
    chmax(res, dp[N][i]);
  }
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>

int main()
{
  int i = 0;
  int x = 0;
int heap[250];

  scanf("%d",&x);
  for(i=1;i<=x;i++)
    {
      scanf("%d",&heap[i]);
    }

  for(i=1;i<=x;i++)
    {
      if(i==1)
	{
	  printf("node %d: key = %d, ",i,heap[i]);
	}
      else
	{
	  printf("node %d: key = %d, parent key = %d, ",i,heap[i],heap[i/2]);
	}
      if(2*i<=x)
	{
	  printf("left key = %d, ",heap[2*i]);
	}
      if(2*i+1<=x)
	{
	  printf("right key = %d, ",heap[2*i+1]);
	}
      printf("\n");
    }
return 0;
}

Measured memory_bytes: 600
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
#define int long long
using namespace std;
int power(int x, int y, int p) 
{ 
    int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
   
        if (y & 1) 
            res = (res*x) % p; 
  
        
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  

int modInverse(int n, int p) 
{ 
    return power(n, p-2, p); 
} 
  

int nCrModPFermat(int n, int r, int p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
 
    int fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 
signed main()
{
    fast;
   
    int x,y;
    cin>>x>>y;
    if((x+y)%3!=0) cout<<"0";
    else
    {
    	int m = (2*x - y)/3;
    	int n = x - 2*m;
        if(n<0 or m<0) cout<<"0";
        else
        {
        	cout<<nCrModPFermat(n+m, min(n,m), mod);
        }

    }
}

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

using namespace std;

int n;

int main()
{
	int n;
	cin >> n;
	int sum = 0;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];

		sum += a[i];
	}
	
	if (sum % 10 != 0) {
		cout << sum << endl;
	}
	else {
		sort(a.begin(), a.end());

		for (int i = 0; i < n; i++) {
			if (a[i] % 10 != 0) {
				cout << sum - a[i] << endl;
				return 0;
			}
		}
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for (int i=0;i<5;i++) {
			int temp = sc.nextInt();
			if (temp ==0) {
				System.out.println(i+1);
			}
		}
	}
}

Measured memory_bytes: 35700