akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; 
} 

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

int arr[MX];

int32_t main() { 
	
	setIO();

	int n; cin >> n;

	F0R(i,n) cin >> arr[i];

    sort(arr,arr+n); int res = 0;
	F0R(i,n) F0R(j,i) F0R(k,j) {
		if (arr[k] != arr[j] && arr[i] != arr[j] && arr[j]+arr[k] > arr[i]) {
            res++;
        }
	}

	cout << res << "\n";

}	

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
int main(){
    string x,y,z;
    cin >> x >> y >> z;
    cout << "A" << y[0] << "C" << endl;
}

Measured memory_bytes: 256
n=int(input())
XYH=[list(map(int,input().split())) for _ in range(n)]

A=[]
cnt,add=0,[0,0]
for i in range(101):
    for j in range(101):
        for x,y,h in XYH:
            H=h+abs(x-i)+abs(y-j)
            A.append([H,i,j])

for H,cx,cy in A:
    flag=1
    for x,y,h in XYH:
        if max(H-abs(x-cx)-abs(y-cy),0)!=h:flag=0
        if not flag:break
    if flag:
        print(cx,cy,H);exit()

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

struct Edge {
  const int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

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

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

int Solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> adj = Make2DVector<int>(n, n, false);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    v1--;
    v2--;
    adj[v1][v2] = adj[v2][v1] = true;
  }

  vector<vector<Edge>> graph(n);
  for (int v1 = 0; v1 < n; v1++) {
    for (int v2 = v1 + 1; v2 < n; v2++) {
      if (!adj[v1][v2]) {
        graph[v1].emplace_back(v1, v2);
        graph[v2].emplace_back(v2, v1);
      }
    }
  }

  vector<int> xs;
  vector<int> ys;
  vector<int> colors(n, -1);
  function<bool(int)> process = [&](int r) -> bool {
    int x = 0;
    int y = 0;
    function<bool(int, int, int c)> dfs = [&](int v, int p, int c) -> bool {
      if (colors[v] >= 0) {
        return colors[v] == c;
      }

      colors[v] = c;
      if (c == 1) y++;
      else x++;

      for (const auto& e : graph[v]) {
        if (!dfs(e.to, v, c ^ 1)) return false;
      }
      return true;
    };

    if (!dfs(r, -1, 0)) return false;

    xs.push_back(x);
    ys.push_back(y);
    return true;
  };

  for (int r = 0; r < n; r++) {
    if (colors[r] >= 0) continue;
    if (!process(r)) return -1;
  }

  int l = xs.size();
  auto dp = Make2DVector(l + 1, n + 1, 0);
  dp[0][0] = 1;
  for (int k = 0; k < l; k++) {
    for (int i = 0; i <= n; i++) {
      if (dp[k][i]) {
        dp[k + 1][i + xs[k]] = 1;
        dp[k + 1][i + ys[k]] = 1;
      }
    }
  }

  int ans = INT32_MAX;
  for (int i = 0; i <= n; i++) {
    if (!dp[l][i]) continue;
    int j = n - i;
    UpdateMin(ans, i * (i - 1) / 2 + j * (j - 1) / 2);
  }
  return ans;
}

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

  cout << Solve() << endl;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 
 int main(){
   ll x,k,d ; cin>>x>>k>>d ;
   if(x>0){
    if((x/d) >= k ) cout<<x-k*d<<endl ;
    else{
      ll p= (x%d) ;
      ll q= (x/d) ;
      if((k-q)%2==0) cout<<p<<endl ;
      else cout<<d-p<<endl ;
    }
   }

   else if(x<0){
   if(((-x)/d) >= k) cout<<-x-k*d<<endl ;
   else{
     ll p= (-x)%d ;
     ll q= (-x)/d ;
     if((k-q)%2==0) cout<<p<<endl ;
      else cout<<d-p<<endl ;
     
   }
   }

   else if(x==0){
     if(k%2==0) cout<<0<<endl ;
     else cout<<d<<endl ;
   }


   return 0 ;
 }



Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;



class Myon
{
	public Myon() { }
	public static int Main()
	{
		cin = new Scanner();
		new Myon().calc();
		return 0;
	}

	static Scanner cin;

	void calc()
	{

		int N = cin.nextInt();
		Dictionary<string, int> count = new Dictionary<string, int>();

		long ans = 0;
		for (int i = 0; i < N; i++)
		{
			string s = cin.next();
			char[] c = s.ToCharArray();
			Array.Sort(c);
			s = new string(c);
			if (!count.ContainsKey(s)) count.Add(s, 1);
			else
			{
				ans += count[s]++;
			}

		}
		Console.WriteLine(ans);
	}


	//swap
	void swap<T>(ref T a, ref T b)
	{
		T c = a;
		a = b;
		b = c;
	}


}



class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		if (s.Length == 0) return next();
		i = 0;
		return s[i++];
	}


	public int nextInt()
	{
		return int.Parse(next());
	}
	public int[] ArrayInt(int N, int add = 0)
	{
		int[] Array = new int[N];
		for (int i = 0; i < N; i++)
		{
			Array[i] = nextInt() + add;
		}
		return Array;
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public long[] ArrayLong(int N, long add = 0)
	{
		long[] Array = new long[N];
		for (int i = 0; i < N; i++)
		{
			Array[i] = nextLong() + add;
		}
		return Array;
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}


	public double[] ArrayDouble(int N, double add = 0)
	{
		double[] Array = new double[N];
		for (int i = 0; i < N; i++)
		{
			Array[i] = nextDouble() + add;
		}
		return Array;
	}

}


Measured memory_bytes: 30796
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
   
        signed main() {
            string no;
         int n0,k,n;
         cin>>no>>k;
         reverse(no.begin(),no.end());
        int m=1,t=no.size()-1,ans=0,p;
        for(int i=k;i>0;i--){
           while(t>=0&&no[t]=='0')t--;
if(t<0)break;
           if(i==3){
               ans+=t*(t-1)*(t-2)*729/6;
              ans+=t*(t-1)*81*((long(no[t]-'0')-1) )/2;
        
           }
           if(i==2){
                 ans+=t*(t-1)*81/2;
               ans+=t*9*(long(no[t]-'0')-1);
           }
           if(i==1){
               ans+=t*9;
               ans+=((long(no[t]-'0')) );
           }

           t--;
        //   cerr<<n;
        }

        

        cout<<ans;

        }


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 2000 + 100;
const int MOD = 1000000000 + 7;

int n, m;
int f[MAXN][MAXN];
int pow2[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> m;
	pow2[0] = 1;
	for(int i = 1; i <= n; i++)
		pow2[i] = (long long)pow2[i - 1] * 2 % MOD;
	f[n + 1][0] = 1;
	for(int i = n; i >= 1; i--)
	{
		int sum = 0;
		for(int j = n; j >= 0; j--)
		{
			sum = (sum + f[i + 1][j]) % MOD;
			f[i][j] = (f[i][j] + sum) % MOD;
			f[i][j + 1] = (f[i][j + 1] + f[i + 1][j]) % MOD;
		}
	}
	int ans = (long long)f[2][n - m] * pow2[max(0, n - m - 1)] % MOD;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
int main(){
    long a,b; cin >> a >> b;
    long c = a*b;
    int r;
    while(b != 0){
        r = a%b;
        a = b;
        b = r;
    }
    cout << c/a << endl;
}

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

int main(){
  int n,y;
  cin>>n>>y;
  int res10000=-1,res5000=-1,res1000=-1;
  for(int a=0;a<=n;++a){
    for(int b=0; b+a<=n; ++b){
      int c=n-a-b;
      int total=10000*a + 5000*b +1000*c;
      if(total==y){
        res10000=a;
        res5000=b;
        res1000=c;
      }
    }
  }
  cout<<res10000<<" "<<res5000<<" "<<res1000<<endl;
}

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

int main() {
  int n;
  cin >> n;
  n %= 1000;

  if (n == 0) cout << 0 << endl;
  else cout << 1000 - n << endl;

  return 0;
}

/*
*/


Measured memory_bytes: 3640
#include <iostream>


int main(){

    int N,K,Q;
    std::cin >>N >>K>> Q;

    int* P= new int[N];
    for (int i=0;i<N;i++){
        P[i]=K-Q;
    }

    int A;
    for (int i=0;i<Q;i++){
        std::cin>>A;
        P[A-1]++;
    }

    for (int i=0;i<N;i++){

        std::cout<<((P[i]>0)?"Yes":"No")<<std::endl;
    }

    
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <set>

using namespace std;

typedef long long int64;
typedef pair<int, int> ii;

const int mod = 1e9 + 7;

class Solution {
private:
    
public:
    int64 solve(int n, string& s) {
        int64 a = 0, b = 0, c = 0, ret = 0;
        for(const auto& cc : s ) {
            if(cc == 'R') ++a;
            else if(cc == 'G') ++b;
            else if(cc == 'B') ++c;
        }
        ret = a * b * c;
        for(int i = 0; i < n; ++i) {
            char& a = s[i];
            for(int j = i + 1; j < n; ++j) {
                char& b = s[j];
                if(a == b) continue;
                int cIdx = 2 * j - i;
                if(cIdx < n && s[cIdx] != a && s[cIdx] != b) --ret;
            }
        }
        
        return ret;
    }

};

int main() {
    int n;
    string s;
    cin >> n >> s;
    Solution sol;
    auto ret = sol.solve(n, s);
    cout << ret << endl;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, w;
    cin >> n >> w;
    vector<long long> dp(w + 1);
    while (n--) {
        int we, va;
        cin >> we >> va;
        for (int j = w - we; j >= 0; --j) {
            dp[j + we] = max(dp[j + we], dp[j] + va);
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << '\n';
    return 0;
}

Measured memory_bytes: 3944
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  map<int, map<int,lint> > m; 
  REP(i,M){
    lint L,R,C;
    cin>>L>>R>>C;
    L--;R--;
    if(m[R][L]==0)m[R][L]=C;
    else m[R][L]=min(m[R][L],C);
  }
  map<int,lint> ans;
  ans[0]=0;
  for(auto em:m){
    ans[em.first]=1e15;
    for(auto e:em.second){
      auto p=ans.lower_bound(e.first);
      if(p==ans.end())continue;
      ans[em.first]=min(ans[em.first],ans[p->first]+e.second);
    }
    auto itr1=ans.lower_bound(em.first);
    // cerr<<itr1->first<<" "<<itr1->second<<endl;
    lint v=itr1->second;
    auto itr2=ans.lower_bound(em.first);
    itr2--;   
    while(itr2->second>=v){
      ans.erase(itr2);
      itr2=ans.lower_bound(em.first);
      itr2--;
    }
    
  }
  if(ans[N-1]==0 or ans[N-1]==1e15){
    cout<<-1<<endl;
  }else{
    cout<<ans[N-1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 21632
#include <stdio.h>

int main(void)
{
	char str[40];
	char str_rev[40];
	int count = 0, i;
	
	scanf("%s", str);
	for (i = 0; str[i] != '\0'; i++) {
		count++;
	}
	
	for (i = 0; i < count; i++) {
		str_rev[i] = str[(count-1) - i];
	}
	
	count = 0;
	for (i = 0; str_rev[i] != '\0'; i++) {
		count++;
	}
	printf("%s\n", str_rev);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

ll comb[52][52];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt = 0, cnt2 = 0;
	for (char c : s) {
		if (c == '(') cnt++;
		else cnt--;
		if (cnt < 0) {
			cnt = 0; cnt2++;
		}
	}
	rep(i, cnt2) cout << '(';
	cout << s;
	rep(i, cnt) cout << ')';
}

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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define EPS (1e-7)
#define INF ((ll)1e9+7)
#define PI (acos(-1))
#define c(a) cout<<a<<"\n";
using namespace std;

int main() {
	speed;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = 0;
	if (a > b)ans += b;
	else ans += a;

	if (c > d)ans += d;
	else ans += c;
	c(ans);
	ed;
	return 0; 
}



Measured memory_bytes: 256
import * as fs from "fs"

function Main(input: string) {

  const vowels: string[] = ["a", "i", "u", "e", "o"]

  const c = input.split("\n")[0]

  if (vowels.indexOf(c) > -1) {
    console.log("vowel")
  }
  else {
    console.log("consonant")
  }

}


fs.readFile('/dev/stdin', (err, data) => {
  if (err) {
    Main(fs.readFileSync('./input.txt', 'utf8'))
    return null
  }
  Main(data.toString())
  return null
})

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int h,w;
  cin>>h>>w;
  int dp[h][w];
  char x;
  rep(i,0,h){
    rep(j,0,w){
      cin>>x;
      if(x=='.') dp[i][j]=1;
      else dp[i][j]=0;
    }
  }
  set<int> r,c;
  rep(i,0,h){
    int ans=1;
    rep(j,0,w){
      ans=ans&dp[i][j];
    }
    if(ans) r.insert(i);
  }
  rep(j,0,w){
    int ans=1;
    rep(i,0,h){
      ans=ans&dp[i][j];
    }
    if(ans) c.insert(j);
  }
  rep(i,0,h){
    if(r.find(i)!=r.end()) continue;
    int flag=0;
    rep(j,0,w){
      if(c.find(j)!=c.end()) continue;
      flag=1;
      if(dp[i][j]) cout<<'.';
      else cout<<'#';
    }

    if(flag) cout<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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

using namespace std;
using ll = long long;

int main() {
    chrono::system_clock::time_point start;
    start = chrono::system_clock::now();

    ios::sync_with_stdio(false);
    cin.tie(0);

    const int INF = 1000000000;

    int d;
    cin >> d;
    vector<int> c(26);
    vector<vector<int>> s(d, vector<int>(26));
    for(int i = 0; i < 26; ++i) cin >> c[i];
    for(int j = 0; j < d; ++j)
        for(int i = 0; i < 26; ++i) cin >> s[j][i];

    int m;
    vector<int> t(d);
    vector<vector<int>> blank(d, vector<int>(26, 1));
    for(int j = 0; j < d; ++j) {
        for(int i = 0; i < 26; ++i) 
            if(j != 0) blank[j][i] = blank[j - 1][i] + 1;
        m = - INF;
        for(int i = 0; i < 26; ++i) {
            if(s[j][i] + c[i] * blank[j][i] > m) {
                t[j] = i;
                m = s[j][i] + c[i] * blank[j][i];
            }
        }
        blank[j][t[j]] = 0;
    }

    int d_, q, dt, diff = 0, m2;
    vector<int> t_ = t;
    vector<vector<int>> blank_ = blank;
    srand((unsigned int)time(NULL));
    while(chrono::duration_cast<chrono::seconds>(chrono::system_clock::now() - start).count() < 0.1) {
        d_ = rand() % d;
        m2 = - INF;
        for(int i = 0; i < 26; ++i) {
            if(s[d_][i] > m2) {
                m2 = s[d_][i];
                q = i;
            }
        }
        // q = rand() % 26;

        diff = 0;

        diff -= s[d_][t_[d_]];
        diff += s[d_][q];

        if(d_ != 0) blank_[d_][t_[d_]] = blank_[d_ - 1][t_[d_]] + 1;
        else blank_[d_][t_[d_]] = 1;
        diff -= c[t_[d_]] * blank_[d_][t_[d_]];
        dt = d_ + 1;
        while(t_[dt] != t_[d_] && dt < d) {
            diff += c[t_[d_]] * blank_[dt][t_[d_]];
            blank_[dt][t_[d_]] = blank_[dt - 1][t_[d_]] + 1;
            diff -= c[t_[d_]] * blank_[dt][t_[d_]];
            dt++;
        }

        diff += c[q] * blank_[d_][q];
        blank_[d_][q] = 0;
        dt = d_ + 1;
        while(t_[dt] != q && dt < d) {
            diff += c[q] * blank_[dt][q];
            blank_[dt][q] = blank_[dt - 1][q] + 1;
            diff -= c[q] * blank_[dt][q];
            dt++;
        }

        t_[d_] = q;

        // printf("%d\n", diff);

        if(diff > 0) {
            t = t_;
            blank = blank_;
        } else {
            t_ = t;
            blank_ = blank;
        }
    }

    for(int j = 0; j < d; ++j) {
        printf("%d\n", t[j] + 1);
    }

    return 0;
}

Measured memory_bytes: 3900
#include <bits/stdc++.h>
#define thik_thik_spat ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back

const llong MOD = 1e9 + 7;

using namespace std;

llong n, a[100001], pref[1000001], cnt, cnt1, q = 0;
llong m, nm;

int main ()
{
    cin >> n >> m >> nm;
    cout << (n - m) % nm;
    return 0;
}

Measured memory_bytes: 256
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1),i=new(r(2))(n.readFileSync("/dev/stdin","utf8").trim().split(/\s+/g));r(4)(i)},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3);t.exports=class{constructor(t){this.inp=new n(t)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=new Array(e),n=0;n<e;n++){var i=t.in(),o=t.in();r[n]={A:i,B:o}}r.sort(function(t,e){return e.A+e.B-(t.A+t.B)});for(var s=0,u=0;u<e;u++)u%2==0?s+=r[u].A:s-=r[u].B;console.log(s)}}]);

Measured memory_bytes: 56352
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c ;
    if(a==b && b==c){
        d=1;
    }else if(a==b || b==c ||a==c){
        d=2;
    }else{
        d=3;
    }
    cout << d << endl;
  


}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_H (300)
#define MAX_W (300)
#define MAX_Q (100000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int H, W, D, As[MAX_H * MAX_W], Q, Ls[MAX_Q], Rs[MAX_Q];
  scanf("%d %d %d", &H, &W, &D);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      scanf("%d", &As[j + i * W]);
    }
  }
  scanf("%d", &Q);
  for (int q = 0; q < Q; q++) {
    scanf("%d %d", &Ls[q], &Rs[q]);
  }

  // reverse
  int Bs[MAX_H * MAX_W + 1];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      Bs[As[j + i * W]] = j + i * W;
    }
  }

  // calculate accumulated cost
  int acc_costs[MAX_H * MAX_W + 1];
  for (int k = 1; k <= D; k++) {
    acc_costs[k] = 0;
    int i_prev = Bs[k] / W, j_prev = Bs[k] % W;
    for (int l = k + D; l <= H * W; l += D) {
      const int i_cur = Bs[l] / W, j_cur = Bs[l] % W;
      acc_costs[l] =
          acc_costs[l - D] + abs(i_cur - i_prev) + abs(j_cur - j_prev);
      i_prev = i_cur;
      j_prev = j_cur;
    }
  }

  for (int q = 0; q < Q; q++) {
    const int L = Ls[q], R = Rs[q];
    printf("%d\n", acc_costs[R] - acc_costs[L]);
  }

  return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    vector<int> a(3);
    for(int i = 0; i < 3; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    cout << a.at(2) - a.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int n;

int s,k,f[6];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    if(n==3){
        cout << 2 << ' ' << 5 << ' ' << 63;
        return 0;
    }
    for(int i=1;i<=30000;i++){
        if(i%2==0 || i%3==0) s+=i,k++,cout << i << ' ';
        if(k==n-2){
            k=i+1;
            for(int i=0;i<6;i++){
                f[(k+i)%6]=k+i;
            }
            break;
        }
    }
    if(s%6==0){
        cout << f[0] << ' ' << f[0]+6;
    }
    if(s%6==1){
        cout << f[2] << ' ' << f[3];
    }
    if(s%6==2){
        cout << f[0] << ' ' << f[4];
    }
    if(s%6==3){
        cout << f[0] << ' ' << f[3];
    }
    if(s%6==4){
        cout << f[0] << ' ' << f[2];
    }
    if(s%6==5){
        cout << f[3] << ' ' << f[4];
    }
}


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

long long MOD  = 1e9 + 7;
vector<int> adj[100002];
long long dp[100002][2];


long long solve(int s, int p, int color){
    
    if(dp[s][color]!=-1) return dp[s][color];
    long long ans = 1;
    for(int child: adj[s]) {
        long long tans = 0;
        if(child==p) continue;
        if(color==0){ //white
            tans+=solve(child,s,  0);
            tans%=MOD;
            tans+=solve(child,s,  1);
            tans%=MOD;
        } else { // black
            tans+=solve(child,s,  0);
            tans%=MOD;
        }
        ans*=tans;
        ans%=MOD;
    }
    
    return dp[s][color]=ans;
}
int main() {
	int n, i;
	cin>>n;
	for(i=1;i<=n;i++)
	    dp[i][0] = dp[i][1]=-1;
	for(i=1;i<=n-1;i++) {
	    int a,b;
	    cin>>a>>b;
	    adj[a].push_back(b);
	    adj[b].push_back(a);
	}
	
	long long ans = solve(1, -1, 1) + solve(1,-1,  0);
	ans%=MOD;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 15616
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    sort(a.begin(),a.end(),greater<int>());
    int alice=0,bob=0;
    rep(i,n){
        if(i % 2 == 0)alice += a[i];
        else bob += a[i];
    }
    cout << alice -bob <<endl;

    return 0;
}

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

struct dice{
	int top;
	int front;
	int left;
	int right;
	int back;
	int bottom;
};

void ClockwiseTop(dice *X){
	int c = X->front;
	X->front  = X->right;
	X->right  = X->back;
	X->back   = X->left;
	X->left   = c;
}

void ClockwiseFront(dice *X){
	int c = X->top;
	X->top    = X->left;
	X->left   = X->bottom;
	X->bottom = X->right;
	X->right  = c;
}

void ClockwiseRight(dice *X){
	int c = X->top;
	X->top    = X->front;
	X->front  = X->bottom;
	X->bottom = X->back;
	X->back   = c;
}

void ClockwiseBottom(dice *X){
	ClockwiseTop(X);
	ClockwiseTop(X);
	ClockwiseTop(X);
}

void ClockwiseBack(dice *X){
	ClockwiseFront(X);
	ClockwiseFront(X);
	ClockwiseFront(X);
}

void ClockwiseLeft(dice *X){
	ClockwiseRight(X);
	ClockwiseRight(X);
	ClockwiseRight(X);
}

void TwiceClockwiseTop(dice *X){
	ClockwiseTop(X);
	ClockwiseTop(X);
}

void TwiceClockwiseRight(dice *X){
	ClockwiseRight(X);
	ClockwiseRight(X);
}

//?????¢??¨?????¢??????????????????????????¢?????¢??°
int Rotation(struct dice X, int t, int f){
	//?????¢????????????
	if(t == X.front ) ClockwiseRight(&X);
	if(t == X.left  ) ClockwiseFront(&X);
	if(t == X.right ) ClockwiseBack(&X);
	if(t == X.back  ) ClockwiseLeft(&X);
	if(t == X.bottom) TwiceClockwiseRight(&X);
	//?????¢????????????
	if(f == X.left  ) ClockwiseBottom(&X);
	if(f == X.right ) ClockwiseTop(&X);
	if(f == X.back  ) TwiceClockwiseTop(&X);
	return X.right;
}

//?????????????????\?????¢??°
dice Enter(dice X){
	cin >> X.top;
	cin >> X.front;
	cin >> X.right;
	cin >> X.left;
	cin >> X.back;
	cin >> X.bottom;
	return X;
}

int main(){
	//????????????????????¢?????°????????\?????????
	dice X = Enter(X);
	//???????????°????????????
	int q;
	cin >> q;
	//??????????????????????????????//?????¢?????????????¨??????????//?????¢??????????????¨?????????
	for(int i = 0; i < q; i++){
		int t, f;
		cin >> t >> f;
		cout << Rotation(X, t, f) << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		long X = long.Parse(str[1]);
		long[]P = new long[51];
		long[]B = new long[51];
		P[0] = 1;
		B[0] = 0;
		for(var i=1;i<=50;i++){
			P[i] = P[i-1]*2+1;
			B[i] = B[i-1]*2+2;
		}
		long ans = fa(N,X,P,B);
		Console.WriteLine(ans);
	}
	public static long fa(int n,long x,long[]P,long[]B){
		long ans = 0;
		if(n==0){
			ans = 1;
		} else if(x<=1){
			ans = 0;
		} else if(x <= 1 + P[n-1] + B[n-1]){
			ans = fa(n-1,x-1,P,B);
		} else if(x <= 1 + P[n-1] + B[n-1] + 1){
			ans = P[n-1] + 1;
		} else if(x <= 1 + P[n-1] + B[n-1] + 1 + P[n-1] + B[n-1]){
			ans = P[n-1] + 1 + fa(n-1,x-1-P[n-1]-B[n-1]-1,P,B);
		} else {
			ans = P[n];
		}
		return ans;
	}
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
//typedef long long int;

vvi g;
vi was;
vi a;

int mex(vi x) {
  x.push_back(1000000);
  sort(x.begin(), x.end());
  int pr = -1;
  for (int i : x) {
    if (i > pr + 1) {
      return pr + 1;
    }
    pr = i;
  }
}

void dfs(int v) {
  if (was[v]) return;
  was[v] = 1;
  vi x;
  for (int nv : g[v]) {
    dfs(nv);
    x.push_back(a[nv]);
  }
  a[v] = mex(x);
}

int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi p(n);
  g.resize(n);
  was.assign(n, 0);
  a.assign(n, 0);
  bool fail = 0;
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    --p[i];
    if (p[i] == i) fail = 1;
    g[p[i]].push_back(i);
  }
  if (fail) {
    cout << "IMPOSSIBLE\n";
    return 0;
  }
  int x = 0;
  for (int i = 0; i < n; ++i) x = p[x];
  for (int i = 0; i < n; ++i) {
    was[x] = 2;
    x = p[x];
  }
  for (int i = 0; i < n; ++i) dfs(i);
  int mi = n;
  vi b(n);
  for (int i = 0; i < n; ++i) if (was[i] == 2) {
    vi x;
    for (int v : g[i]) if (was[v] == 1) x.push_back(a[v]);
    b[i] = mex(x);
    mi = min(mi, b[i]);
  }
  for (int i = 0; i < n; ++i) {
    int pr = x;
    x = p[x];
    if (b[x] == mi && b[pr] != mi) break;
  }
  bool ok = 0;
  for (int t = 0; t < 3 && !ok; ++t) {
    was.assign(n, 0);
    a.assign(n, 0);
    was[x] = 1;
    a[x] = mi;
    for (int i = 0; i < n; ++i) dfs(i);
    ok = 1;
    for (int i = 0; i < n; ++i) {
      vi x;
      for (int v : g[i]) x.push_back(a[v]);
      if (mex(x) != a[i]) ok = 0;
    }
    x = p[x];
  }
  if (ok) {
    cout << "POSSIBLE\n";
  } else {
    cout << "IMPOSSIBLE\n";
  }
  return 0;
}

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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


int main(){
    ll x;
    cin>>x;

    ll a,b;
    ll ansa,ansb;
    for(ll i=-118;i<120;i++){
        for(ll j=-119;j<119;j++){
            a = i*i*i*i*i;
            b = j*j*j*j*j;
            if(a-b==x){
                ansa = i;
                ansb = j;
                break;
            }
        }
    }
    cout<<ansa<<" "<<ansb<<endl;

}


Measured memory_bytes: 3556
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
b = a[::-1]
ans = 0
from heapq import heapify,heappop,heappush

for l in range(1,k+1):
  ans_l = 0
  ans_r = 0
  for j in range(1,l+1):
    left = a[:j]
    chk_l = sum(left)
    heapify(left)
    heappush(left,0)
    for jj in range(l-j):
      p = heappop(left)
      if p >= 0:
        break
      chk_l -= p
    ans_l = max(ans_l,chk_l)
    
  if l < n:
    r = k-l
    for j in range(1,r+1):
      m = min(j,n-l)
      right = b[:m]
      chk_r = sum(right)
      heapify(right)
      heappush(right,0)
      for jj in range(r-m):
        q = heappop(right)
        if q >= 0:
          break
        chk_r -= q
      ans_r = max(ans_r,chk_r)
      
  ans = max(ans,ans_r+ans_l)
print(ans)

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

int n;
long a[100010], lo[50010], le[50010], ro[50010], re[50010], t;

int main(){
	cin >> n;
	lo[0] = 0;
	le[0] = 0;
	ro[(n-1)/2] = 0;
	re[(n+1)/2] = 0;
	for (int i = 0; i < n; ++i){
		cin >> a[i]; 
		if (i % 2 == 0) le[i/2+1] += le[i/2] + a[i];
		else lo[(i+1)/2] += lo[(i-1)/2] + a[i];
	}
	for (int i = n-1; i >= 0; --i){
		if (i % 2 == 0) re[i/2] += re[i/2+1] + a[i];
		else ro[(i-1)/2] += ro[(i+1)/2] + a[i];
	}
	for (int i = 0; i < n; ++i){
		if (i % 2 == 0){
			t = -le[i/2] + re[i/2] + lo[i/2] - ro[i/2];
		}
		else{
			t = le[(i+1)/2] - re[(i+1)/2] - lo[(i-1)/2] + ro[(i-1)/2];
		}
		cout << t << " ";
	}
	cout << endl;
}

Measured memory_bytes: 3712
import sys
input = sys.stdin.readline

def main():
    N, M, X = map(int, input().split())
    ca = [list(map(int, input().split())) for _ in range(N)]

    ans = sys.maxsize
    for mask in range(2 ** N):
        C = 0
        A = [0] * N
        for i in range(N):
            if ((mask >> i) & 1):
                C += ca[i][0]
                A = [a + c for a, c in zip(A, ca[i][1:])]
        if all([i >= X for i in A]):
            ans = min(ans, C)
    if ans != sys.maxsize:
        print(ans)
    else:
        print("-1")

main()

Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
   
    long long int n,k;
     cin>>n>>k;
     if(n<k)
     {
         if(n<abs(n-k))
            cout<<n<<endl;
         else
           cout<<abs(n-k)<<endl;
     }
         
           
      else{
         long long int p;
        p=n%k;
        if(p<(k-p))
             cout<<p<<endl;
        else
           cout<<k-p<<endl;
         
      
      
}
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int H[25];
    int count = 1;
    int bfo;
    for(int i = 0; i < N; ++i){
        cin >> H[i];        
    }
    bool flag = true;
    for(int j = 1; j < N; j++){
        for(int k = 0; k < j; k++){
            if(H[k] > H[j]){
                flag = false;
            }
        }
        if(flag) count++;
        flag = true;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,m,n) for(int i=m;i<n;i++)
#define repr(i,n,m) for(int i=n;i>=m ;i--)
#define mod 1000000007
#define float long double
#define pb push_back
#define mp make_pair
#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
using namespace std;
bool sortbysec(const pair<int,int> &a,
             const pair<int,int> &b)
{
   return (a.second < b.second);
}

bool sortinrev(const pair<int,int> &a,  
              const pair<int,int> &b)
{
      return (a.first > b.first);
}
void solve()
{
	int n,m,total=0;
	cin>>n>>m;
	int arr[n];
	rep(i,0,n){
	cin>>arr[i];
	total+=arr[i];}
	int x=ceil((float)total/(4*m));
	sort(arr,arr+n,greater<int>());
	rep(i,0,m)
	{
		if(arr[i]<x)
		{
			cout<<"No";
			return;
		}
	}cout<<"Yes";
}
signed main()
{
     // #ifndef ONLINE_JUDGE
     //    freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
     //     #endif 	
  int t=1;
  //cin>>t;
  while(t--){
  solve(); 
  cout<<"\n";
}
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
 return 0;
}  


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

int main(){
 int n; cin >> n;
 string s; cin >> s;
 int cnt=0;
 for(int i=0;i<n-2;i++)
 if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')cnt++;
 cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int X,Y,mon=0;
    scanf("%d %d",&X,&Y);

    if(X == 1) mon += 300000;
    else if(X == 2) mon += 200000;
    else if(X == 3) mon += 100000;

    if(Y == 1) mon += 300000;
    else if(Y == 2) mon += 200000;
    else if(Y == 3) mon += 100000;

    if (X == 1 && Y == 1) mon += 400000;
  
   //printf("X = %d,Y=%d\n",X,Y);

    printf("%d",mon);
    return 0;
}

Measured memory_bytes: 128
(ns Atcoder.ABC079-C)
(def S (read-line))
(def len (count S))
(defn char2int [c]  (- (int c) (int \0)))
(defn calc [i]
  (loop [j 1 sum (char2int (first S))]
    (if (= len j)
      sum
      (if (= (bit-and 1 (bit-shift-right i (dec j))) 1)
        (recur (inc j) (+ sum (char2int (nth S j))))
        (recur (inc j) (- sum (char2int (nth S j)))
      )
    )
  )))

(def ans_pattern (for [i (range 0 (Math/pow 2 (dec len))) :when (= (calc i) 7)] i))

;(def x for [i (range 0 (Math/pow 2 (dec len))) :when (= (calc i) 7)] i)

(defn pattern2format [pattern]
  (def form (loop [j 1 form (str (nth S 0))]
              (if (= len j)
                (str form (str "=7"))
                (if (= (bit-and 1 (bit-shift-right pattern (dec j))) 1)
                  (recur (inc j) (str form "+" (nth S j)))
                  (recur (inc j) (str form "-" (nth S j)))))))

  (println form)
  )

(pattern2format (int (first ans_pattern)))

Measured memory_bytes: 87532
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#define MOD 1000000007
typedef long long ll; 
ll dp[5005], nxt[5005], fact[5005], inv[5005]; 
inline ll quick_pow(ll a, int n)
{
	ll res = 1; 
	while (n)
	{
		if (n & 1)
			res = res * a % MOD; 
		a = a * a % MOD; 
		n >>= 1; 
	}
	return res; 
}
inline ll C(int n, int m)
{
	return fact[n] * inv[m] % MOD * inv[n - m] % MOD; 
}
int lst[5005], to[10005], pre[10005], tot; 
int sz[5005], seq[5005], n; 
inline void add_edge(int u, int v)
{
	to[tot] = v; 
	pre[tot] = lst[u]; 
	lst[u] = tot++; 
}
void dfs(int u, int fa = -1)
{
	int mx = 0; 
	sz[u] = 1; 
	for (int i = lst[u]; ~i; i = pre[i])
	{
		if (to[i] == fa)
			continue; 
		dfs(to[i], u); 
		sz[u] += sz[to[i]]; 
		mx = std::max(mx, sz[to[i]]); 
	}
	mx = std::max(mx, n - sz[u]); 
	if (mx << 1 == n)
	{
		printf("%lld\n", fact[mx] * fact[mx] % MOD);
		exit(0); 
	}
	if (mx << 1 > n)
		return; 
	int cnt = 0, len = 0; 
	for (int i = lst[u]; ~i; i = pre[i])
	{
		if (to[i] != fa)
			seq[cnt++] = sz[to[i]]; 
	}
	if (u)
		seq[cnt++] = n - sz[u]; 
	memset(dp, 0, sizeof(dp)); 
	dp[0] = 1; 
	for (int i = 0; i < cnt; i++)
	{
		memset(nxt, 0, sizeof(nxt)); 
		for (int j = 0; j <= seq[i]; j++)
		{
			for (int k = 0; k <= len; k++)
				(nxt[j + k] += dp[k] * C(seq[i], j) % MOD * C(seq[i], j) % MOD * fact[j]) %= MOD; 
		}
		len += seq[i]; 
		memcpy(dp, nxt, sizeof(nxt)); 
	}
	ll ans = 0; 
	for (int i = 0; i <= len; i++)
		(ans += (i & 1 ? -1 : 1) * dp[i] * fact[n - i]) %= MOD; 
	printf("%lld\n", (ans + MOD) % MOD);
	exit(0); 
}
int main()
{
	// freopen("ARC087-F.in", "r", stdin); 
	memset(lst, -1, sizeof(lst)); 
	scanf("%d", &n); 
	for (int i = 1; i < n; i++)
	{
		int u, v; 
		scanf("%d%d", &u, &v); 
		add_edge(--u, --v); 
		add_edge(v, u); 
	}
	fact[0] = inv[0] = 1; 
	for (int i = 1; i <= n; i++)
	{
		fact[i] = fact[i - 1] * i % MOD; 
		inv[i] = quick_pow(fact[i], MOD - 2); 
	}
	dfs(0); 
	return 0; 
}


Measured memory_bytes: 768
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (X >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



}






Measured memory_bytes: 3628
#!/usr/bin/ruby
s=gets.chomp
r=0
(1<<(s.size-1)).times{|i|
	x=0
	s.size.times{|j|
		x=x*10+s[j].to_i
		if i[j]==1
			r+=x
			x=0
		end
	}
	r+=x
}
p r

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<vector>
using namespace std;
const int INF = 200000005;
int main()
{
	int a, b;
	cin >> a >> b;
	int s = b-a;
	int ans=0;
	for (int i = 1; i <= s; i++) {
		ans += i;
	}
	cout << ans - b << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		WriteLine(GetStrings(GetInt()).Distinct().Count());
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 55412
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  ll H,W;
  cin>>H>>W;
  if (H == 1 || W == 1){
    cout << 1 << endl;
  }else{
    cout << (H*W+1)/2 << endl;
  }
  return 0;
}


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

int main() {
  string S,T;
  cin >> S >>T ;

 if(S.at(0) == T.at(0) && S.at(1) == T.at(1) && S.at(2) == T.at(2)){
    cout << 3 << endl;
}else if(S.at(0) != T.at(0) && S.at(1) != T.at(1) && S.at(2) != T.at(2)){
  cout << 0 << endl;
}else if((S.at(0) == T.at(0) && S.at(1) != T.at(1) && S.at(2) != T.at(2)) ||
(S.at(0) != T.at(0) && S.at(1) == T.at(1) && S.at(2) != T.at(2))||
(S.at(0) != T.at(0) && S.at(1) != T.at(1) && S.at(2) == T.at(2))
){
  cout << 1 << endl;
}else{
  cout << 2 << endl;
}
}

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


void solve(long long N, std::vector<long long> P, std::vector<long long> Q){
    auto v = vector<long long>(N, 0);
    for(int i=0; i < N; i++){
        v[i] = i + 1;
    }
    int pi, qi;
    int ind = 0;
    do {
        if(v == P){
            pi = ind;
        }
        if(v == Q){
            qi = ind;
        }
        ind++;
  } while (std::next_permutation(v.begin(), v.end()));
  cout << abs(pi - qi) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    std::vector<long long> Q(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&Q[i]);
    }
    solve(N, std::move(P), std::move(Q));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int a[m],b[m];
  vector<vector<int>> v;
  v.resize(n+1);
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];
    v.at(a[i]).push_back(b[i]);
  }
  for(int i=1;i<n+1;i++){
    sort(v.at(i).begin(),v.at(i).end());
  }
  for(int i=0;i<m;i++){
    if(a[i]<10)
      cout<<"00000";
    else if(a[i]<100)
      cout<<"0000";
    else if(a[i]<1000)
      cout<<"000";
    else if(a[i]<10000)
      cout<<"00";
    else if(a[i]<100000)
      cout<<"0";
    cout<<a[i];
    if(1+lower_bound((v.at(a[i])).begin(),(v.at(a[i])).end(),b[i])-v.at(a[i]).begin()<10)
      cout<<"00000";
    else if(1+lower_bound((v.at(a[i])).begin(),(v.at(a[i])).end(),b[i])-v.at(a[i]).begin()<100)
      cout<<"0000";
    else if(1+lower_bound((v.at(a[i])).begin(),(v.at(a[i])).end(),b[i])-v.at(a[i]).begin()<1000)
      cout<<"000";
    else if(1+lower_bound((v.at(a[i])).begin(),(v.at(a[i])).end(),b[i])-v.at(a[i]).begin()<10000)
      cout<<"00";
    else if(1+lower_bound((v.at(a[i])).begin(),(v.at(a[i])).end(),b[i])-v.at(a[i]).begin()<100000)
      cout<<"0";
    cout<<1+lower_bound((v.at(a[i])).begin(),(v.at(a[i])).end(),b[i])-v.at(a[i]).begin()<<endl;
  }
}


Measured memory_bytes: 7808