akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
#define vbi vector<bool> 
#define mod 1000000007
#define INF 1000000000
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
ll i,j,k;
void solve()
{
 ll n; cin>>n;
 vector<pair<long long,long long >> v;
 for(i=0;i<n;i++){
     ll x,y; cin>>x>>y;
     v.pb(mp(x,y));
 }
 vector<double> v1;
ld sum=0;
 for(i=0;i<n;i++){
  for(j=i+1;j<n;j++){
     ld x=v[i].ft;
     ld y=v[i].sd;
      ld a=v[j].ft;
     ld b=v[j].sd;
     x=abs(x-a);
     y=abs(y-b);
     x=x*x;
     y=y*y;
     x=x+y;
     x=sqrt(x);
      v1.pb(x);
      sum=sum+x;
  }
 }
 sum=sum*2;
 sum=sum/n;
 cout<<setprecision(7)<<fixed<<sum;

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

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

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

typedef unsigned long ul;
using namespace std;

int n, k;
string s;

void solve() {
    string a = s;
    char hoge = s[k - 1];
    REP(i, n) {
        if (hoge != a[i]) {
            a[i] = '*';
        }
    }
    cout << a;
}

int main() {
    cin >> n >> s >> k;
    solve();
    return 0;
}


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


int top,S[1000];

void push(int x){
  top++;
  S[top] = x;
}

int pop(){
  top--;
  return S[top+1];
}


int main(){
  int x;
  char s[100];//tmp
  int a,b,top=0;

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    } else if ( s[0] == '-' ){
      b = pop();
      a = pop();
      push(a-b);
    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a*b);
    } else {
      push(atoi(s));
    }
  }

  printf("%d\n", pop());

  return 0;
}


Measured memory_bytes: 3160
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 3e18;
const string sp = " ";

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 modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n == r) return 1;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int nck[1010][1010];
void comb(int n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

int n;
string s, ans;
signed main() {
	cin >> n >> s;
	ans += s[0];
	rep(i, n) {
		if (i == 0) continue;
		if (s[i] != s[i - 1]) ans += s[i];
	}
	cout << ans.size() << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int a[5];
	for(int i = 0; i < 5; i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+3);
	sort(a+3,a+5);
	printf("%d\n",a[0]+a[3]-50);
	return 0;
}

Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
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; }
 
lli cnts[1000100];
bool vis[1000100];
 
int main(){
    // cout << fixed << setprecision(5);
 
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        cnts[A[i]]++;
    }
 
    SORT(A);
    lli ans = 0;
    REP(i,0,N){
        if(vis[A[i]] || cnts[A[i]] == 0)continue;
        for(lli j=2;A[i]*j<1000100;j++){
            cnts[A[i]*j]=0;
        }
        if(cnts[A[i]]==1)ans++;
        vis[A[i]]=true;
    }
 
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13548
N = int(input())
hotels = [int(i) for i in input().split()]
count = 0
max_height = 0
for i in range(len(hotels)):
    if i == 0:
        count += 1
        max_height = hotels[0]
    else:
        if hotels[i] >= max_height:
            count += 1
            max_height = hotels[i]
print(count)


Measured memory_bytes: 3060
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n;
            cin>>n;
            cout<<(1000-n%1000)%1000<<endl;
        }
        return 0;
    }


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        long[] a =  new long[n];
        long mod = 1000000007;
      	for(int i=0;i<n;i++){
      		a[i]=sc.nextLong()%mod;
      	}
      	long sum=0;
      	for(int i=0;i<n;i++){
      		sum=(sum+a[i])%mod;
      	}
      long ans=0;
      long sum2=0;
      for(int i=0;i<n;i++){
    	  sum2=(sum2+a[i]*a[i])%mod;
      }
      ans=(sum*sum-sum2);
      while(ans<0){
    	  ans=ans+mod;
      }
      if(ans%2==1){ans=ans+mod;}
      ans=ans/2;
      ans=ans%mod;
      System.out.println(""+ans);
	}
}

Measured memory_bytes: 61988
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC160
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            string s = Console.ReadLine();
            if(s[2] == s[3] && s[4] == s[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        List<String> A = new ArrayList<>();
        A.add("SUN");
        A.add("MON");
        A.add("TUE");
        A.add("WED");
        A.add("THU");
        A.add("FRI");
        A.add("SAT");

        String S = next();

        for(int i=0; i<7; i++){
            if(A.get(i).equals(S)){
                println(7-i);
                return;
            }
        }
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 25300
#include <iostream>
#include <algorithm>
using namespace std;
int alp[3];
int main(){
  string s;cin>>s;
  for(int i = 0; s.size() > i; i++)alp[s[i]-'a']++;
  int de = min(alp[0],min(alp[1],alp[2]));
  for(int i = 0; 3 > i; i++){
    //cout << alp[i] << " " << de << endl;
    if(alp[i]-de > 1){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	while(cin>>s) {
		REP(i, s.size()) {
			if(s[i]=='?') s[i]='D';
		}
		cout<<s<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3404
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] alpha = new int[26];
		for (int i = 0; i < n; i++) {
			char c = sc.next().charAt(0);
			alpha[c - 'A']++;
		}
		Arrays.sort(alpha);
		for (int i = n / k; i > 0; i--) {
			int count = n - i * k;
			for (int j = 25; j >= 0; j--) {
				int x = alpha[j];
				if (x <= i) {
					break;
				}
				count -= x - i;
				if (count < 0) {
					break;
				}
			}
			if (count >= 0) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(0);
	}
}


Measured memory_bytes: 29688
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int N;
    int M;
    cin >> N;
    cin >> M;
    
    int easytime = (N - M) * 100;
    int hardtime = M * 1900;
    
    int ret;
    ret = (easytime + hardtime) * pow(2, M);
    
    cout << ret << endl;
    
    return 0;
}

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

int main(){
  int n,t0=0,x0=0,y0=0,t1,x1,y1,dif=0,dif_t=0;cin>>n;

  for(int i=0;i<n;++i){
    cin>>t1>>x1>>y1;
    dif=abs(x0-x1)+abs(y0-y1);
    dif_t=t1-t0;
    if((dif%2!=dif_t%2)||dif>dif_t){
      puts("No");
      return 0;
    }
    t1=t0;
    x1=x0;
    y1=y0;
  }puts("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
struct UnionFind{
  int n;
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};
int N,M;
int ed[705][705],dp[705];
//main
signed main(){
  cin>>N>>M;
  while(M--){
    int a,b;cin>>a>>b;a--;b--;
    ed[a][b]++;ed[b][a]++;
  }
  std::vector<int> used(N,-1);
  typedef pair<int,int> P;
  std::vector<P> si;
  queue<int> que;
  for(int i=0;i<N;i++){
    if(~used[i])continue;
    que.push(i);used[i]=0;int s=1,t=0;
    while(que.size()){
      int p=que.front();que.pop();
      for(int j=0;j<N;j++){
        if(p==j||ed[p][j])continue;
        if(used[j]==used[p])fin(-1);
        if(~used[j])continue;
        used[j]=used[p]^1;
        if(used[j])t++; else s++;
        que.push(j);
      }
    }
    si.push_back(P(s,t));
  }
  dp[0]=1;
  for(P p:si){
    for(int i=700;i>=0;i--){
      if(dp[i]){
        dp[i]=0;
        dp[i+p.first]=dp[i+p.second]=1;
      }
    }
  }
  int ans=LINF;
  for(int i=0;i<=700;i++){
    if(!dp[i])continue;
    ans=min(ans,i*(i-1)/2+(N-i)*(N-i-1)/2);
  }
  if(ans>INF)fin(-1);fin(ans);
}


Measured memory_bytes: 4096
#include<iostream>
using namespace std;
int n,m,a[10000];
int main(){
	while(true){
		cin>>n>>m;if(n==0)break;
		for(int i=0;i<n;i++)cin>>a[i];
		int m1=1<<30,m2=0,m3=n;
		for(int i=0;i<n;i++){
			int M=(m/a[i])*a[i];
			if(m1>M){m1=M;m2=a[i];m3=i+1;}
			else if(m1==M){
				if(m2>a[i]){m2=a[i];m3=i+1;}
				else if(m2==a[i]){m3=n;}
			}
		}
		cout<<m3<<endl;
	}
	return 0;
}

Measured memory_bytes: 1168
// finish date: 2018/06/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <functional>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pii pair<int,int>
const int bigmod = 1000000007;
#define INF 1050000000


int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        vi p(n);
        rep(i, n) {
            cin >> p[i];
        }
        int maxDP = n * 1000;
        vector<pii > DP(maxDP, pii(-1, -1));
        DP[0] = pii(0, 0);
        vector<pii > newDP;
        rep(i, n) {
            newDP = vector<pii >(maxDP, pii(-1, -1));
            int otsuri = 1000 - p[i] % 1000;
            if (otsuri == 1000) otsuri = 0;
            for (int j = maxDP - 1; j >= 0; j--) {
                if (DP[j] == pii(-1, -1)) continue;
                bool con1 = newDP[j + otsuri].first < DP[j].first;
                bool con2 = newDP[j + otsuri].first == DP[j].first;
                bool con3 = newDP[j + otsuri].second > DP[j].second + p[i];
                if (con1 || (con2 && con3)) {
                    newDP[j + otsuri] = DP[j];
                    newDP[j + otsuri].second += p[i];
                }
            }
            rep(j, maxDP) {
                if (newDP[j] == pii(-1, -1)) continue;
                if (j >= 500) {
                    bool con1 = newDP[j - 500].first < newDP[j].first + 1;
                    bool con2 = newDP[j - 500].first == newDP[j].first + 1;
                    bool con3 = newDP[j - 500].second > newDP[j].second;
                    if (con1 || (con2 && con3)) {
                        newDP[j - 500] = newDP[j];
                        newDP[j - 500].first++;
                    }
                }
            }
            rep(j, maxDP) {
                if (DP[j].first > newDP[j].first || (DP[j].first == newDP[j].first && DP[j].second < newDP[j].second)) {
                    newDP[j] = DP[j];
                }
            }
            DP = newDP;
        }



        int ma = -1;
        int ansMoney = 0;
        rep(i, maxDP) {
            if (DP[i].first > ma || (DP[i].first == ma && DP[i].second < ansMoney)) {
                ma = DP[i].first;
                ansMoney = DP[i].second;
            }
        }
        cout << ma << " " << ansMoney << endl;

    }


    return 0;
}







Measured memory_bytes: 5236
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> A;
    A.pb(1);
    int a = 1;
    while(a <= N) {
        a *= 6;
        A.pb(a);
    }
    a = 1;
    while(a <= N) {
        a *= 9;
        A.pb(a);
    }
    vector<int> B(N + 1, inf);
    B[0] = 0;
    rep(i, N + 1) {
        for(int a: A){
            if(i + a <= N) {
                B[i + a] = min(B[i + a], B[i] + 1);
            }
        }
    }
    output(B[N]);
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }

  int times=0, flag=0;
  while(flag==0){
    for(int i=0;i<N;i++){
      if(A[i]%2==0) A[i] = A[i]/2;
      else flag = 1;
    }
    if(flag==0) times += 1;
    else break;
  }

  cout << times << endl;
  return 0;
}

Measured memory_bytes: 256
MODULE gcdMod
! 最小公倍数GCDを求めるモジュール
! ユークリッドの互除法を使用する．
! MODはとっていない.
      IMPLICIT NONE
      
      interface gcd
        module procedure :: intGcd
      end interface
      
      integer(16),parameter,private :: precision = 16
      
      contains
      function intGcd( a,b ) result( gcd )
        implicit none
        integer(precision),intent(in) :: a,b
        integer(precision) :: gcd, smaller, bigger, remain
        
        bigger  = max( a,b )
        smaller = min( a,b )
        
        do while(.true.)
          remain = mod( bigger,smaller )
          if( remain==0 )then
            gcd = smaller; return
          else
            bigger  = smaller
            smaller = remain
          end if
        end do
      end function
      end MODULE gcdMod
      
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      

      PROGRAM piyo
      use gcdMod
      IMPLICIT NONE
      integer(16) :: n,ans
      integer(16),allocatable :: a(:)
      integer(16) :: i
      
      read*,n
      allocate( a(n) )
      read*,a(1:n)
      
      ans = a(1)
      
      do i = 2,n
        ans = gcd( ans,a(i) )
      end do
      
      print*,ans
      
      
      
      
      END PROGRAM

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
  int a, b, c = 0, d = 0, e = 0;
  while(~scanf("%d,%d", &a, &b)) {
    c += a*b;
    d += b;
    e++;
  }

  cout << c << endl << round((double)d/e) << endl;
  return 0;
}

Measured memory_bytes: 3308
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n, a, b, c, d;
  cin>>n>>a>>b>>c>>d;
  --a;
  --b;
  --c;
  --d;
  string s;
  cin>>s;
  bool ans=true;
  for(int i=a; i<c; ++i){
    if(s[i]=='#'&&s[i+1]=='#')ans=false;
  }
  for(int i=b; i<d; ++i){
    if(s[i]=='#'&&s[i+1]=='#')ans=false;
  }
  if((d-c)<0){
    bool sw = false;
    for(int i=b; i<=d; ++i){
      if(i==n-1) continue;
      if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') sw=true;
    }
    ans=ans&sw;
  }

  cout<<(ans?"Yes":"No")<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
using namespace std;

const long waru = pow(10, 9) + 7;

long factorial(long a)
{
  long r = a;
  while (0 < --a) {
    r = (r * a) % waru;
  }
  return r;
}

int main()
{
  long n, m, f;
  cin >> n >> m;
  f = (n - m) * (n - m);
  if (f > 1) {
    cout << 0 << endl;
    return 0;
  }
  if (f == 0) {
    cout << (factorial(n) * factorial(m) * 2) % waru << endl;
  } else {
    cout << (factorial(n) * factorial(m)) % waru << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;


main(){
    int n;cin>>n;
    ll a[n];
    ll ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;i<n;i++){
        ll diff = a[i-1]-a[i];
        if(a[i]<a[i-1]) {ans+= (diff);
        a[i]+= diff;
        }
    } 
    cout<<ans;
}

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

int main() {
    int n, m; cin >> n >> m;
    int ans = 1;
    repp(i,sqrt(m)+1,1){
        if (m % i != 0) continue;
        if (m/i >= n) ans = max(ans,i);
        if (i >= n) ans = max(ans,m/i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
N,M=map(int,input().split())
k=[list(map(int,input().split())) for _ in range(M)]
p=list(map(int,input().split()))

ans=0
for i in range(2**N):
    switch=[False]*N

    for j in range(N):
        if ((i>>j) & 1):
            switch[N-j-1]=True

    light=True
    for m in range(M):
        cnt=0
        for o in range(k[m][0]):
            if switch[k[m][o+1]-1]==True:
                cnt+=1

        if not (cnt%2==p[m]):
            light=False

    if light==True:
        ans+=1
      
            
print(ans)

Measured memory_bytes: 3064
list = input().split()
W = int(list[0])
H = int(list[1])
x = int(list[2])
y = int(list[3])
r = int(list[4])

if ((x-r) < 0 or (x+r) > W or (y-r) < 0 or (y+r) > H):
    print('No')
else:
    print('Yes')


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

using namespace std;

const int N = 100010;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int r, d, x;
    cin >> r >> d >> x;
    for (int i = 1; i <= 10; i++) {
        int foo = r * x - d;
        cout << foo << endl;
        x = foo;
    }
    return 0;
}

Measured memory_bytes: 256
# A - Table Tennis Training
N,A,B = map(int, input().split())

if (B-A) % 2 == 0:
    ans = int((B-A)//2)
else:
    # ansB1 = A-1
    # ansB2 = int((B - A-1) / 2)
    # ansB = A-1 +1+ ansB2

    ansC2 = int((B - A-1) // 2)
    ans = min(N-B,A-1) +1+ ansC2

print(int(ans))

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>

using namespace std;

int main(){
    int N;
    string A, B, C;
    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;
    
    int ans = 0;
    for(int i=0; i<N; i++){
        if(A[i] == B[i] && B[i] == C[i]) continue;
        if(A[i] == B[i] || B[i] == C[i] || C[i] == A[i]){
            ans++;
            continue;
        }
        ans += 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
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 ll mod=1e9+7;

double dp[310][310][310];
ll n;

double rec(ll i,ll j,ll k){
    if(dp[i][j][k]>=0) return dp[i][j][k];
    if(i==0 && j==0 && k==0) return 0.0;
    double res=0;
    if(i>=1) res+=rec(i-1,j,k)*i;
    if(j>=1) res+=rec(i+1,j-1,k)*j;
    if(k>=1) res+=rec(i,j+1,k-1)*k;
    res+=n;
    res*=1.0/(i+j+k);
    return dp[i][j][k]=res;
}

int main(){
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin>> a[i];
    }
    memset(dp,-1,sizeof(dp));
    ll one=0;
    ll two=0;
    ll three=0;
    rep(i,n){
        if(a[i]==1) one++;
        if(a[i]==2) two++;
        if(a[i]==3) three++;
    }
    cout << fixed << setprecision(20) << rec(one,two,three) << endl;
    return 0;
} 

Measured memory_bytes: 233088
N=int(input())
from collections import Counter
c=Counter(map(int,input().split()))
f=1
for i in range((N+1)%2,(N+1)//2,2):
    if i==0 and c[i]!=1 or 0<i and c[i]!=2:
        f=0
print(pow(2,N//2,10**9+7) if f else 0)

Measured memory_bytes: 22260
#include<stdio.h>
int main(){
    int i,j,k,n,m,l,a[100][100],b[100][100];
    long int c[100][100]={0};
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            if(j>0){
                printf(" ");
            }
            printf("%ld",c[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2148
import java.util.Scanner;
     
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		String input = scan.next();
    		long sum = 0;
    		int itr = 1;
    		for (int i = 0; i < input.length() - 1; i++) {
    			itr *= 2;
    		}
    		for (int combi = 0; combi < itr; combi++) {
    			int i = 0;
    			while (i < input.length()) {
    				int j = i;
    				while ((combi & (1 << j)) == 0) {
    					j++;
    					if (j >= input.length() - 1) {
    						j = input.length() -1;
    						break;
    					}
    				}
    				sum += Long.valueOf(input.substring(i, j + 1));
    				i = j + 1;
    			}
    		}
    		System.out.println(sum);
    	}
     
    }

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

int main() {
    int n;
    int max_w;
    cin >> n >> max_w;
    vector<int>w(n);
    vector<int>v(n);
    unsigned long long dp[n][max_w+1];

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

    for (int i=0;i<n;i++) {
        for (int M=0; M<=max_w; M++) {

            if (w[i] > M && i == 0) {
                dp[i][M] = 0;
            }
            else if (w[i] <= M && i == 0) {
                dp[i][M] = v[i];
            }
            else if (M - w[i] >= 0 && i > 0) {
                dp[i][M] = max(dp[i-1][M], dp[i-1][M-w[i]] + v[i]);
            }
            else {
                dp[i][M] = dp[i-1][M];
            }
        }
    }
    cout << dp[n-1][max_w];
}

Measured memory_bytes: 78336
#include<iostream>
#include<string>
#include<vector>
#include<sstream>
using namespace std;
string s="true";
string i2s(int n){
  stringstream x;
  x<<n;
  return x.str();
}
bool calc(int a,int b){
  if(a+b==10) {
    s+="+";
    return true;
  }
  if(a-b==10){
    s+="-";
    return true;
  }
  if(a*b==10) {
    s+="*";
    return true;
  }
  return false;
}
bool calc(int a,int b, int c){
  if(calc(a+b,c)) {
    s+="0+";
    return true;
  }
  if(calc(a-b,c)) {
    s+="0-";
    return true;
  }
  if(calc(a*b,c)) {
    s+="0*";
    return true;
  }
  if(calc(a,b+c)) {
    s+="1+";
    return true;
  }
  if(calc(a,b-c)) {
    s+="1-";
    return true;
  }if(calc(a,b*c)) {
    s+="1*";
    return true;
  }
  
  return false;
}

bool calc(int a,int b, int c, int d){
  
  if(calc(a+b,c,d)) {
    s+="0+";
    return true;
  }
  if(calc(a-b,c,d)) {
    s+="0-";
    return true;
  }
  if(calc(a*b,c,d)) {
    s+="0*";
    return true;
  }
  if(calc(a,b+c,d)) {
    s+="1+";
    return true;
  }
  if(calc(a,b-c,d)){
    s+="1-";
    return true;
  }
  if(calc(a,b*c,d)) {
    s+="1*";
    return true;
  }
  if(calc(a,b,c+d)) {
    s+="2+";
    return true;
  }
  if(calc(a,b,c-d)) {
    s+="2-";
    return true;
  }
  if(calc(a,b,c*d)){
    s+="2*";
    return true;
  }
  
  return false;
}
int main(){
  int a[4];
  while(cin>>a[0]>>a[1]>>a[2]>>a[3],a[0]||a[1]||a[2]||a[3]){
    int i,j,k,l;
    int bi,bj,bk,bl;
    bool f=false;
    s="";
    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	for(k=0;k<4;k++){
	  for(l=0;l<4;l++){
	    if(i==j||i==k||i==l||j==k||j==l||k==l) continue;
	    if(calc(a[i],a[j],a[k],a[l])){
	      bi=i;bj=j;bk=k;bl=l;
	      f=true;
	      break;
	    }
	  }
	  if(f) break;
	}
	if(f) break;
      }
      if(f) break;
    }
    if(f){
      //cout << s << endl;
      //cout << a[bi] << a[bj] << a[bk] << a[bl] << endl;
      vector<string> b;
      b.push_back(i2s(a[bi]));b.push_back(i2s(a[bj]));
      b.push_back(i2s(a[bk]));b.push_back(i2s(a[bl]));
      
      string o="";
      o+="(";
      o+=(b[s[3]-'0']);
      o+=s[4];
      o+=(b[s[3]-'0'+1]);
      o+=")";
      b[s[3]-'0']=o;
      b.erase(b.begin()+(s[3]-'0')+1);
      o="";
      o+="(";
      o+=(b[s[1]-'0']);
      o+=s[2];
      o+=(b[s[1]-'0'+1]);
      o+=")";
      b[s[1]-'0']=o;
      b.erase(b.begin()+(s[1]-'0')+1);
      o="";
      o+="(";
      o+=(b[0]);
      o+=s[0];
      o+=(b[1]);
      o+=")";
      b[0]=o;
      b.erase(b.begin()+1);
      cout << b[0] << endl;
    }
    else cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >


using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10,mod=1e9+7;

int main ()
{
    FASTIO
    ll n;
    cin >> n;
    ll x=100,cnt=0;
    while(1){
        cnt++;
        x += x/100;
        if(x>=n)return cout << cnt << endl,0;
    }
    return 0;
}
/**

*/


Measured memory_bytes: 3640
N = int(input())
S = list(input())
visited = {}

count = 0

for i, s in enumerate(S):
    if s in visited:
        continue
    visited[s] = []
    for j, s2 in enumerate(S[i+1:N-1]):
        # print(s, s2, S[i + j + 2:N])
        if s2 in visited[s]:
            continue
        count += len(set(S[i + j + 2:N]))
        visited[s].append(s2)
        # print(s, s2, set(S[j + 1:N]))
print(count)

Measured memory_bytes: 62700
N = int(input())
AList = list(map(int, input().split()))
Q = int(input())
dp = [0]*(10**5+1)
total = 0
for i in AList:
  dp[i] += 1
  total += i
  
for i in range(Q):
  B,C = map(int, input().split())
  bNum = dp[B]
  dp[B] = 0
  dp[C] += bNum
  cNum = dp[C]
  total = total - B*bNum + C*bNum
  print(total)

Measured memory_bytes: 20820
#include <iostream>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i =0;i < N;i++){
    int b = 0;
    cin >> b;
    a[i] = b;
  }
  sort(a, a + N, greater<int>());
  int total = 0;
  for(int i = 1;i < N;i ++){
    total += a[i];
  }
  if(a[0] < total){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
a,b,c=[],[],[]
ans=0
for i in range(n):
  if s[i] not in a:
    a.append(s[i])
    b=[]
    for j in range(i+1,n):
      if s[j] not in b:
        b.append(s[j])
        c=[]
        for k in range(j+1,n):
          if s[k] not in c:
            c.append(s[k])
            ans+=1
print(ans)

Measured memory_bytes: 3064
# coding: utf-8
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces


def main():
    s = ns()
    if s == 'ABC':
        print('ARC')
    else:
        print('ABC')
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 61884
/*Templates are for weak. -invictus_123*/
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int main() {
 	int n, W;
 	long long s = 0;
 	scanf("%d%d", &n, &W);   
 	vector <int> w(n), v(n);
 	for(int i = 0; i < n; i ++) {
 		scanf("%d%d", &w[i], &v[i]);
 		s += v[i];
 	}
 	vector <long long> dp(s + 1, INF);
 	dp[0] = 0;
 	for(int i = 0; i < n; i ++) {
 		for(int j = s; j >= v[i]; j --) {
 			dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
 		}
 	}
 	long long ans = 0;
 	for(int i = 0; i <= s; i ++) {
 		if(dp[i] <= W) {
 			ans = i;
 		}
 	}
 	printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 1024
path = {}
for i in range(1,5):
    city = int(i)
    path[i] = 0


for i in range(3):
    city_1 ,city_2 = map(int,input().split())
    path[city_1] += 1
    path[city_2] += 1

d = 1
for value in path.values():
    d *= value

if d == 4:
    print("YES")
else:
    print("NO")

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

int main(void)
{
  long long unsigned int a, b, x, y, gcd, lcm, r;

  while(scanf("%llu %llu", &a, &b) != EOF)
    {
      r = 1;
      x = a;
      y = b;

      while(r != 0)
	{
	  r = x % y;
	  x = y;
	  y = r;
	}
      gcd = x;

      lcm = a * b / gcd;

      cout << gcd << " " << lcm << endl;
    }
  return 0;
}

Measured memory_bytes: 0
Card = Struct.new(:suit, :rank) {
  def value
    rank
  end

  def to_s
    "#{suit}#{rank}"
  end
}

def bubble_sort(arr)
  has_unordered = true
  stable = true

  while has_unordered
    has_unordered = false

    for i in (1...arr.length).to_a.reverse
      if (x=arr[i]).value < arr[i-1].value
        arr[i] = arr[i-1]
        arr[i-1] = x
        has_unordered = true
        stable = false if arr[i].value == arr[i-1].value
      end
    end
  end

  puts arr.join(" ")
  puts stable ? "Stable" : "Not stable"
end

def selection_sort(a) # N個の要素を含む0-オリジンの配列A
  stable = true
  for i in 0...(a.length)
    found_same_value = false
    minj = i
    for j in i...(a.length)
      case a[j].value <=> a[minj].value
      when -1
        minj = j
        stable = false if found_same_value
      when 0
        found_same_value = true if j != i
      end
    end
    old_ai = a[i]
    a[i] = a[minj]
    a[minj] = old_ai
  end

  puts a.join(" ")
  puts stable ? "Stable" : "Not stable"
end

gets

arr = gets.split.map{|card| Card.new(card[0], card[1].to_i)}

bubble_sort(arr.clone)
selection_sort(arr.clone)



Measured memory_bytes: 6896
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	chunks := strings.Split(sc.Text(), " ")
	n, _ := strconv.Atoi(chunks[0])
	timeout, _ := strconv.Atoi(chunks[1])

	minCost := math.MaxInt64

	for i := 0; i < n; i++ {
		sc.Scan()
		chunks := strings.Split(sc.Text(), " ")
		t, _ := strconv.Atoi(chunks[1])
		if t > timeout {
			continue
		}
		c, _ := strconv.Atoi(chunks[0])
		if c < minCost {
			minCost = c
		}
	}

	if minCost == math.MaxInt64 {
		fmt.Println("TLE")
	} else {
		fmt.Println(minCost)
	}
}


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

class dice {
public:
	int getTopFace(void);
	int getRightFace(int top, int front);
	void rotate(char dir);
	void setFaceNumber(int *number);
private:
	int face[6];
};

int dice::getTopFace(void) {
	return face[0];
}

void dice::rotate(char dir) {
	int temp;
	switch(dir) {
	case 'N' :
		temp=face[0];
		face[0]=face[1];
		face[1]=face[5];
		face[5]=face[4];
		face[4]=temp;
		break;
	case 'S' :
		temp=face[0];
		face[0]=face[4];
		face[4]=face[5];
		face[5]=face[1];
		face[1]=temp;
		break;
	case 'W' :
		temp=face[0];
		face[0]=face[2];
		face[2]=face[5];
		face[5]=face[3];
		face[3]=temp;
		break;
	case 'E' :
		temp=face[0];
		face[0]=face[3];
		face[3]=face[5];
		face[5]=face[2];
		face[2]=temp;
		break;
	}
}

void dice::setFaceNumber(int *number) {
	for(int i=0; i<6; ++i) {
		face[i]=number[i];
	}
}

int dice::getRightFace(int top, int front) {
	int pos_top, pos_front;
	string str;
	string target_str;
	for(int i=0; i<6; ++i) {
		if(face[i]==top) pos_top=i;
		if(face[i]==front) pos_front=i;
	}
	str = to_string(pos_top)+to_string(pos_front);
	target_str="01540";
	if((int)target_str.find(str)!=-1) {
		return face[2];
	}
	target_str="04510";
	if((int)target_str.find(str)!=-1) {
		return face[3];
	}
	target_str="02530";
	if((int)target_str.find(str)!=-1) {
		return face[4];
	}
	target_str="03520";
	if((int)target_str.find(str)!=-1) {
		return face[1];
	}
	target_str="12431";
	if((int)target_str.find(str)!=-1) {
		return face[0];
	}
	target_str="13421";
	if((int)target_str.find(str)!=-1) {
		return face[5];
	}
	return 0;
}

int main() {
	int num[6];
	int n,top,front;
	dice d;
	cin >> num[0] >> num[1] >> num[2] >> num[3] >> num[4] >> num[5];
	d.setFaceNumber(num);
	cin >> n;
	for(int i=0; i<n; ++i) {
		cin >> top >> front;
		cout << d.getRightFace(top,front) << endl;
	}
	return 0;
}

Measured memory_bytes: 3288
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,a[100002],ans;
int main(){
	n=read();
	printf("%d",360/__gcd(360,n));
}

Measured memory_bytes: 3764
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
		int c=sc.nextInt();
		
    
 	if((a+b)<=(b+c)&&(a+b)<=(c+a)){
    		System.out.println(a+b);
    	}else if((b+c)<=(c+a)&&(b+c)<=(a+b)){
     		System.out.println(b+c);
   	 }else{

    	System.out.println(c+a);
    }
    }
}

Measured memory_bytes: 21716
from collections import defaultdict

if __name__ == '__main__':
    MOD = 2019
    strS = input()
    S = [int(s) for s in strS]
    N = len(S)

    mods = defaultdict(int)
    mods[0] += 1
    pow10_mod = 1
    prv_mod = 0
    for idx, s in enumerate(S[::-1]):
        tmp_mod = (prv_mod + s * pow10_mod) % MOD

        mods[tmp_mod] += 1
        pow10_mod = (pow10_mod * 10) % MOD
        prv_mod = tmp_mod

    ans = 0
    for key, value in mods.items():
        if value >= 2:
            ans += value * (value - 1) // 2

    print(ans)


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

int main() {
  double A; double B; double C;
  cin>>A>>B>>C;
  if(max(max(A,B),C)==A){
    cout<<B*C/2<<endl;
  }
    else if(max(max(A,B),C)==B){
      cout<<A*C/2<<endl;
    }
    else if(max(max(A,B),C)==C){
      cout<<A*B/2<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n,w;
    cin>>n>>w;
    vector<vector<vector<ll> > > dp(n+1, vector<vector<ll> >(n+1, vector<ll>(n*3+1,0)));
    ll weight[n],value[n];
    rep(i,n)cin>>weight[i]>>value[i];
    ll base=weight[0];
    rep(i,n)weight[i]-=base;
    for(int i=1;i<=n;i++)for(int j=0;j<=i;j++)for(int k=0;k<=n*3;k++){
        if(j==0)continue;
        dp[i][j][k]=dp[i-1][j][k];
        if(k>=weight[i-1]){
            dp[i][j][k]=max(dp[i-1][j-1][k-weight[i-1]]+value[i-1],dp[i-1][j][k]);
        }
    }
    DEBUG{cout << "1 1 0 : "<<dp[1][1][0] << endl; }
    ll res=0;
    rep(i,n+1)rep(j,n*3+1){
        if(i*base+j>w)continue;
        DEBUG{
            printf("i : %d, j : %d dp : %lld\n", i,j,dp[n][i][j]);
        }
        res=max(res,dp[n][i][j]);
    }
    cout << res << endl;
    return 0;
}


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

int main()
{
	int d, g; cin >> d >> g;
	
	vector<int> p(d), c(d); for (int i = 0; i < d; i++) cin >> p[i] >> c[i];

	int ans = 2147483647;
	for (int bit = 0; bit < (1<<d); bit++) {

		vector<bool> f(d, false);
		int tmp_score = 0;
		int tmp_ans = 0;
		int maxIndex = -1;
		for (int i = 0; i < d; i++) {			

			if (bit & (1 << i)) {
				tmp_score += c[i] + 100 * (i + 1) * p[i];
				tmp_ans += p[i];
				f[i] = true;
			}
			else {
				maxIndex = i;
			}

		}
		
		if (maxIndex == -1) {
			ans = min(ans, tmp_ans);
		}
		else {
			if (g <= tmp_score) {
				ans = min(ans, tmp_ans);
			}
			else {
				for (int i = 0; i < p[maxIndex] - 1; i++) {
					tmp_score += 100 * (maxIndex + 1);
					tmp_ans++;
					if (g <= tmp_score) {
						ans = min(ans, tmp_ans);
						break;
					}					
				}
			}
		}
		
	}	

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

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

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

using namespace std;

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

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

	int sx,sy;
	rep(i,h) rep(j,w) if(B[i][j]=='S') {
		B[i][j]='.';
		sx=i;
		sy=j;
	}

	vector d(h,vector(w,INF));
	d[sx][sy]=0;
	queue<pair<int,int>> Q; Q.emplace(sx,sy);
	while(!Q.empty()){
		int x,y;
		tie(x,y)=Q.front(); Q.pop();

		rep(k,4){
			int x2=x+dx[k],y2=y+dy[k];
			if(0<=x2 && x2<h && 0<=y2 && y2<w && B[x2][y2]=='.' && d[x2][y2]==INF){
				d[x2][y2]=d[x][y]+1;
				Q.emplace(x2,y2);
			}
		}
	}

	int ans=INF;
	rep(i,h) rep(j,w) if(d[i][j]<=n) ans=min(ans,1+(min({i,j,h-i-1,w-j-1})+n-1)/n);
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 7060
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(void){
  int N,i;
  cin >> N;
  string W[N];
  for(i=0; i<N; i++){
    cin >> W[i];
  }

  char end=W[0][W[0].length()-1];
  for(i=1;i<N;i++){
    if(end!=W[i][0]){
      cout<<"No";
      exit(0);
    }
    end=W[i][W[i].length()-1];
  }

  sort(W,W+N);
  for(i=0;i<N-1;i++){
    if(W[i]==W[i+1]){
      cout<<"No";
      exit(0);
    }
  }
  cout<<"Yes";
}


Measured memory_bytes: 256