akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

int main() {
    ll a, b; cin >> a >> b;
    ll ans = -1;
    if (a > 1) {
        ll temp = -1;
        if ((a - 1) % 4 == 0) {
            temp = a - 1;
        }
        else if ((a - 1) % 4 == 1) {
            temp = 1;
        }
        else if ((a - 1) % 4 == 2) {
            temp = (a - 1) ^ 1;
        }
        else {
            temp = 0;
        }

        if (b % 4 == 0) {
            ans = b;
        }
        else if (b % 4 == 1) {
            ans = 1;
        }
        else if (b % 4 == 2) {
            ans = b ^ 1;
        }
        else {
            ans = 0;
        }


        ans = ans ^ temp;
    }
    else {
        if (b % 4 == 0) {
            ans = b;
        }
        else if (b % 4 == 1) {
            ans = 1;
        }
        else if (b % 4 == 2) {
            ans = b ^ 1;
        }
        else {
            ans = 0;
        }
    }

    cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

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

#endif

void Main() {
    int N, M;
    cin >> N >> M;
    vector<P> keys;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j, b) {
            int c;
            cin >> c;
            c--;
            s |= 1 << c;
        }
        keys.emplace_back(s, a);
    }
    vector<ll> dp(1 << N, INF);
    dp[0] = 0;
    rep(s, 1 << N) {
        rep(i, M) {
            ll t = s | keys[i].first;
            ll cost = dp[s] + keys[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    ll ans = dp.back();
    if (ans == INF) {
        cout << -1 << '\n';
    }else{
        cout << ans << '\n';
    }
}

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


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

int n,k;
string s;

int main(){

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

    cin>>n>>k;
    cin>>s;
    s[k-1]+='a'-'A';
    cout<<s<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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



int main() {
    ll x, y;
    cin >> x >> y;
    cout << ((abs(x - y) <= 1) ? "Brown" : "Alice") << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int x;
  int D = 0;
  
  for (int i=0; i<N; i++) {
    cin >> x;
    if (x <= K-x)
      D += x*2;
    else
      D += (K-x)*2;
  }
  
  cout <<D <<endl;
}


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

int main(){
	string s;

	cin >> s;

	if (s.at(s.size()-1) == 's')
		cout << s << "es" << endl;
	else
		cout << s << 's' << endl;
	
	return (0);
}



Measured memory_bytes: 3628
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, m; cin>>n>>m;

    cout << (n == m ? "Yes" : "No") << endl;

    return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    int n;
    cin>>n;
    int x,y;
    int cnt=0;
    int f=0;
    while(n--)
    {
        cin>>x>>y;
        if(x==y)cnt++;
        else cnt=0;
        if(cnt==3)f=1;
        
    }
    if(f)cout<<"Yes";
    else cout<<"No";
}


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

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)

const ll MAX = 1e5+10;
const ll MOD = 1e9+10;

ll N;
vi A;

int main() {
    cin >> N;
    A = vi(N);
    REP (i, N) cin >> A[i];
    sort(A.begin(), A.end());

    int a = A[0], b = A[N-1];
    string txt = "";
    FOR(i,1,N-1) {
        if (A[i] < 0) {
            txt += to_string(b) + " " + to_string(A[i]) + "\n";
            b -= A[i];
        } else {
            txt += to_string(a) + " " + to_string(A[i]) + "\n";
            a -= A[i];
        }
    }
    txt += to_string(b) + " " + to_string(a) + "\n";
    cout << b-a << endl;
    cout << txt;
}

Measured memory_bytes: 4608
import sys


def main():
	input = sys.stdin.readline
	N, M, L = list(map(int,input().split()))
	P = [list(map(int,input().split())) for i in range(M)]
	Q = int(input())
	st = [list(map(int,input().split())) for i in range(Q)]

	neighbor = [[] for i in range(N)]
	for s,e,d in P:
		if d<=L:
			neighbor[s-1].append((e-1,d))
			neighbor[e-1].append((s-1,d))
		# if d<=L:
		# 	neighbor[s-1][e-1] = neighbor[e-1][s-1] = d

	# print(neighbor)
	# start, end = 2,1

	fuellist = [0]*N
	def bfs(start, end):
		# fuel = [[10000000,L+1] for i in range(N)]
		fuelc, fuelm = [10000000]*N, [L+1]*N
		# fuel[start][0] = 0
		# fuel[start][1] = L
		fuelc[start], fuelm[start] = 0, L
		queue = [start]
		while len(queue)>0:
			nq = []						# next target node
			nq_append = nq.append
			for i in queue:				# target node
				oc, om = fuelc[i], fuelm[i]
				for j, d in neighbor[i]:
				# for j, d in enumerate(neighbor[i]):	# next node
					# if d==10**10: continue
					if om<d:
						nc = oc+1
						nm = L-d
					else:
						nc = oc
						nm = om-d

					# print(i,j,nc,nm)

					if nc<fuelc[j]:
						fuelc[j], fuelm[j] = nc, nm
						nq_append(j)
					elif nc==fuelc[j] and nm>fuelm[j]:
						fuelm[j] = nm
						nq_append(j)

			queue = nq					# update target node

		# ans = fuel[end][0]
		ans = fuelc[end]
		if ans==10000000: ans = -1

		fuellist[start] = fuelc

		print(ans)

	for s, t in st:
		start, end = s-1, t-1

		if fuellist[start]!=0:
			ans = fuellist[start][end]
			if ans==10000000: ans = -1
			print(ans)
		elif fuellist[end]!=0:
			ans = fuellist[end][start]
			if ans==10000000: ans = -1
			print(ans)
		else:
			bfs(start,end)


if __name__ == '__main__':
	main()

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

using namespace std;

int main(int argc, char *argv[]) {
    string s;
    cin >> s;

    int sz = s.size();

    //  0 から始める場合
    //  奇数番目が0
    //  偶数番目が1
    int change = 0;
    for (int i = 0; i < sz; i++) {
        if (i % 2 == 0 && s[i] != '0') {
            change++;
        }
        if (i % 2 == 1 && s[i] != '1') {
            change++;
        }
    }

    //  1 から始める場合
    //  奇数番目が1
    //  偶数番目が0
    int change1 = 0;
    for (int j = 0; j < sz; j++) {
        if (j % 2 == 0 && s[j] != '1') {
            change1++;
        }
        if (j % 2 == 1 && s[j] != '0') {
            change1++;
        }
    }

    cout << min(change, change1) << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}
const int N=2E5+1;
ll f[N];
int n;

inline ll cr(int m){
    return powmod( (f[n-m] * f[n-m-1]%MOD) * (f[m] * f[m] %MOD),MOD-2,MOD);
}
int main() {
    READ(0);
    int k;cin>>n>>k;
    f[0]=f[1]=1;
    for(int i=2;i<=n;++i) f[i] = (f[i-1]*i)%MOD;
    ll ret=0;
    for(int m=1;m<min(k+1,n);++m){
        ret += cr(m);
        if (ret>=MOD) ret -= MOD;
    }
    ret = ret * (f[n]*f[n-1]%MOD) %MOD;
    if (++ret==MOD) ret=0;
    cout << ret;

    return 0;
}



Measured memory_bytes: 1792
X=gets.to_i
K=gets.to_i
r=[0,0,*gets.split.map(&:to_i)]
Q=gets.to_i
l=m=q=k=0
h=X
$<.each{|e|
	t,a=e.split.map &:to_i
	while k<r.size-1 && t>=r[k+1]
		m+=z=(-1)**q*(r[k+1]-r[k])
		l=[X,[l+z,0].max].min
		h=[X,[h+z,0].max].min
		q+=1
		k+=1
	end
	z=(-1)**q*(t-r[k])+[h,[l,a+m].max].min
	p [X,[z,0].max].min
}

Measured memory_bytes: 13972
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
typedef long long ll;
 
struct edge { int s, t, d; };
int V, E, R;
const ll Inf = 1L << 56;
 
int main(int argc, char *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  cin >> V >> E >> R;
  edge es[E];
  ll d[V];
  REP(i,V) d[i] = Inf;
  d[R] = 0;
  REP(i,E) cin >> es[i].s >> es[i].t >> es[i].d;
  while (true) {
    bool update = false;
    REP(i,E) {
      edge e = es[i];
      if (d[e.s] == Inf)
        continue;
      ll dd = d[e.s] + e.d;
      if (d[e.t] > dd) {
        d[e.t] = dd;
        update = true;
      }
    }
 
    if (!update)
      break;
  }
 
  REP(i,V) {
    if (d[i] == Inf) {
      cout << "INF\n";
    } else {
      cout << d[i] << '\n';
    }
  }
  cout << flush;
     
  return 0;
}

Measured memory_bytes: 9648
#include <iostream>
#include <cstring>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
	string str;
	cin >> str;
	int cnt = 0;
	int ans = 0;
	rep(i,str.size()){
		if(str[i] != 'O'){
			if(cnt == 0) continue;
			if(i-cnt*2 < 0 || i+cnt-1 >= str.size()) continue;
			bool ok = true;
			for(int j = i-cnt*2; j < i-cnt; j++) if(str[j] != 'J') ok = false;
			for(int j = i; j < i+cnt; j++) if(str[j] != 'I') ok = false;
			if(ok) ans = max(ans,cnt);
			cnt = 0;
		} else{
			cnt++;
		}
	}
	cout << ans << endl;
}

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

int main(){
    string s;
    int q;
    cin >> s >> q;
    int is_reverse = 0;
    rep(i, q){
        int ti;
        cin >> ti;
        if (ti == 1) is_reverse++;
        else{
            int fi;
            cin >> fi;
            if ((fi==1 && is_reverse%2==0) || fi==2 && is_reverse%2==1){
                string ci;
                cin >> ci;
                s.insert(0,ci);
            } else {
                char ci;
                cin >> ci;
                s.push_back(ci);
            }
        }
    }
    if (is_reverse%2 == 1) reverse(s.begin(), s.end());
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 900
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {

	void solve() {
		n = in.nextInt();
		int k = in.nextInt();
		int x[] = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = in.nextInt();
		}
		ret = 0;
		for (int i = 0; i < n; i++) {
			ret += Math.min(x[i], Math.abs(k - x[i])) * 2;
		}
		out.println(ret);
	}

	// only call
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	// predefined
	FastScanner in = new FastScanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	int n, m, a, b, c, d, e, f;
	int ret;
	ArrayList<Integer> list = new ArrayList<>();
	ArrayDeque<Integer> q = new ArrayDeque<>();

	// 2D-map
	int H, W;
	final int[] dw = new int[] { 0, 1, 0, -1, 1, 1, -1, -1 };
	final int[] dh = new int[] { 1, 0, -1, 0, 1, -1, 1, -1 };

	boolean inField(int nw, int nh) {
		if (nw < 0 || nw >= W || nh < 0 || nh >= H) {
			return false;
		}
		return true;
	}

	// Yes/No
	static String yesno(boolean f) {
		return yesno(f, "Yes", "No");
	}

	static String yesno(boolean f, String yes, String no) {
		return (f ? yes : no);
	}

	// library
	class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		FastScanner(InputStream in) {
			this.in = in;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}

Measured memory_bytes: 21204
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n, k, min;
      n=Integer.parseInt(sc.next());
      k=Integer.parseInt(sc.next());
      int[] h = new int[n];
      for(int i=0; i<n; i++){
        h[i]=Integer.parseInt(sc.next());
      }

      Arrays.sort(h);
      min=h[k-1]-h[0];
      for(int i=1; i<n-k+1; i++){
        if(h[i+k-1]-h[i]<min){
          min=h[i+k-1]-h[i];
        }
      }

      System.out.println(min);
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 48212
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int[] arr = {sc.nextInt(), sc.nextInt(), sc.nextInt()};
    Arrays.sort(arr);

    System.out.println(arr[0] + arr[1] == arr[2] ? "Yes" : "No");
  }
}


Measured memory_bytes: 23764
N = int(input())
A = list(map(int, input().split()))

from collections import defaultdict
c = defaultdict(int)
cm = set()
c2 = list()
num = 0
for i in range(N):
  c[A[i]] += 1
  cm.add(A[i])
for i in list(cm):
  num += c[i]*(c[i]-1)//2
for i in range(N):
  ans = num - c[A[i]] + 1
  c2.append(ans)

for cs in c2:
  print(cs)

Measured memory_bytes: 31644
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		double x,y,b,p,suma=0,sumb=0;
		cin>>x>>y>>b>>p;
		suma=x*b+y*p;
		if(b>=5&&p>=2) suma=suma*4/5;
		if(b<5) b=5;
		if(p<2) p=2;
		sumb=(x*b+y*p)*4/5;
		cout<<min(suma,sumb)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> vec(n);
    rep(i,n) cin >> vec[i];
    int sum=0;
    rep(i,n){
        sum+=vec[i];
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    int num=sum/(4*m);
    if(sum%(4*m)!=0) num++;
    if(vec[m-1]>=num) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>

#define DIV 1000000007
using namespace std;

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

    vector<int> a(N);
    for (int& x : a)
        cin >> x;

    vector<int>cnt(N);
    long long ans = 1;
    for (int i = 0; i < N; i++) {
        cnt[a[i]]++;
        if (a[i] == 0) {
            ans *= (3 - cnt[a[i]] + 1);
        }
        else
            ans *= (cnt[a[i] - 1] - cnt[a[i]] + 1);
        if (ans <= 0)break;
        ans %= DIV;
        //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;int x[100005],y[100005];bool mk[405][405];
int main() {int n,m,ans=0;
    scanf("%d%d",&n,&m);for (register int i=1;i<=m;++i) scanf("%d%d",x+i,y+i);
    for (register int i=1;i<=n;++i) {mk[i][i]=1;
        for (register int j=m;j;--j) {
            if (mk[i][x[j]]&&mk[i][y[j]]) {*mk[i]=1;break;}
            if (mk[i][x[j]]) mk[i][y[j]]=1;
            else if (mk[i][y[j]]) mk[i][x[j]]=1;
        }
    }
    for (register int i=1;i<=n;++i) for (register int j=i+1;j<=n;++j) {
        if (mk[i][0]||mk[j][0]) continue;bool flag=true;
        for (register int k=1;k<=n;++k) if (mk[i][k]&&mk[j][k]) {flag=false;break;}
        ans+=flag;
    }printf("%d",ans);return 0;
}

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

int cnt;
char f[16][16];
bool v[16][16];

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

void chk(int x, int y, char c)
{
	if(c!=f[y][x]) return;
	v[y][x] = 1;

	cnt++;
	for(int i=0; i<4; i++)
	{
		int nx = x+dx[i];
		int ny = y+dy[i];

		if(nx<0 || 6<=nx || ny<0 || 12<=ny) continue;
		if(v[ny][nx]) continue;

		chk(nx, ny, c);
	}
}

void ers(int x, int y, char c)
{
	if(c!=f[y][x])
	{
		if(f[y][x] == 'O')
		{
			f[y][x] = '.';
		}
		return;
	}
	f[y][x] = '.';

	for(int i=0; i<4; i++)
	{
		int nx = x+dx[i];
		int ny = y+dy[i];

		if(nx<0 || 6<=nx || ny<0 || 12<=ny) continue;

		ers(nx, ny, c);
	}
}

void g(int x)
{
	int b=12;

	for(int y=11; y>=0; y--)
	{
		if(f[y][x]!='.')
		{
			b--;
			f[b][x] = f[y][x];
			if(b!=y) f[y][x] = '.';
		}
	}
}


int main()
{
	int N;
	cin >> N;
	while(N--)
	{
		for(int y=0; y<12; y++)
		{
			cin >> f[y];
		}

		int  ans=0;
		bool flag;

		do
		{
			flag=false;

			for(int y=0; y<12; y++)
			for(int x=0; x<6;  x++)
			{
				if(f[y][x]=='.' || f[y][x]=='O') continue;

				cnt=0;
				memset(v,0,sizeof(v));
				chk(x,y,f[y][x]);

				if(cnt>=4)
				{
					flag=true;
					ers(x,y,f[y][x]);
				}
			}

			for(int x=0; x<6; x++)
			g(x);

			if(flag) ans++;
		}
		while(flag);

		cout << ans << endl;
	}
}

Measured memory_bytes: 0
n, h = map(int, input().split())
amax = 0
bs = []
for i in range(n):
  a, b = map(int, input().split())
  amax = max(amax, a)
  bs.append(b)
bs = sorted([i for i in bs if i >= amax], reverse=True)
ans = 0
for i in bs:
  h -= i
  ans += 1
  if h <= 0:
    break
else:
  ans += (h + amax - 1) // amax
print(ans)


Measured memory_bytes: 8972
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    char s[50][50];
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> s[i][j];
        }
    }

    int flag = 0;

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(s[i][j] == '#'){
                //角
                if(i==0 && j==0){
                    if(s[1][0]=='.' && s[0][1]=='.')
                        flag = 1;
                }else if(i==(H-1) && j==0){
                    if(s[i-1][0]=='.' && s[i][1]=='.')
                        flag = 1;
                }else if(i==0 && j==(W-1)){
                    if(s[0][j-1]=='.' && s[1][j]=='.')
                        flag = 1;
                }else if(i==(H-1)&&j==(W-1)){
                    if(s[i][j-1]=='.' && s[i-1][j]=='.')
                        flag = 1;
                }else if(j==0){//左隅
                    if(s[i-1][j]=='.' && s[i][j+1]=='.' && s[i+1][j]=='.')
                        flag = 1;
                }else if(i==0){//上隅
                    if(s[i][j-1]=='.' && s[i+1][j]=='.' && s[i][j+1]=='.')
                        flag = 1;
                }else if(j==W-1){//右隅
                    if(s[i-1][j]=='.' && s[i][j-1]=='.' && s[i+1][j]=='.')
                        flag = 1;
                }else if(i==H-1){//下隅
                    if(s[i][j-1]=='.' && s[i-1][j]=='.' && s[i][j+1]=='.')
                        flag = 1;
                }else{//その他
                    if(s[i][j-1]=='.' && s[i-1][j]=='.' && s[i][j+1]=='.' && s[i+1][j]=='.')
                        flag = 1;
                }
            }
        }
    }


    if(flag == 0)
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    n = int(input())
    ab = [list(map(int, input().split())) for i in range(n)]
    ans = 0
    for i in range(n):
        tmp = ans + ab[n - i - 1][0]
        cnt = tmp % ab[n - i - 1][1]
        if cnt:
            ans += ab[n - i - 1][1] - cnt

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27204
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=13)
        cout<<b;
    else if(a>=6 && a<=12)
        cout<<b/2;
    else if(a<=5)
        cout<<0;
   //while solving this problem.....I'm in my way to fail the next exam.
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int,int> 
#define fi first
#define pb push_back
#define si second
#define int long long int
using namespace std;

int32_t main(){
	string s,t;
	cin>>s>>t;
	if(s==t.substr(0,s.length()))
		cout<<"Yes\n";
	else cout<<"No\n";	
	
			
}

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

int main(){
    int n;
    cin>>n;
    long long int s=0;
    int a[10000], b[10000];
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<n; i++) cin>>b[i];
    for(int i=0; i<n; i++){
        if(a[i]>b[i]){
            s-=a[i]-b[i];
        }
        else if(b[i]-a[i]>=2){
            s+=(b[i]-a[i])/2;
        }
    }
    if(s>=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 384
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
cd = [list(map(int,input().split())) for i in range(n)]
ab.sort()
cd.sort()
cnt = 0
for i, j in cd:
	x = []
	for k,l in ab:
		if k < i and l < j:
			x.append([k,l])
	if len(x) > 0:
		cnt += 1
		xx = sorted(x, key=lambda x:x[1])
		ab.remove(xx[-1])
print (cnt)


Measured memory_bytes: 3064
n, m = map(int, input().split())
a = [0] * (n + 1)
b = [0] * (n + 1)
price = [0] * (n + 1)
ans = 0

shop = [tuple(map(int, input().split())) for _ in range(n)]
shop.sort()

for i in range(1, n + 1):
    a_i, b_i = shop[i - 1]
    a[i] = a[i - 1]
    b[i] = b[i - 1]
    price[i] = a_i
    a[i] += a_i * b_i
    b[i] += b_i

for i in range(1, n + 1):
    if m <= b[i]:
        m = m - b[i - 1]
        ans = a[i - 1] + price[i] * m
        break
print(ans)


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

int n, k;
bool m[10];

int main(){

ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);

cin >> n >> k;

for(int i=1,x;i<=k;i++){
cin >> x;
m[x] = 1;
}

for(int i=n;;i++){
	int v = i;
	bool ok = 1;

	while (v != 0) {
		int last = v % 10;

		if (m[last]) {
			ok = 0;
		}		
		
		v /= 10;
	}

	if (ok) {
		cout << i;
		break;
	}
}

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1LL;
   if(pow < 0) return 0;
   base %= mod;
   while(pow!=0){if(pow&1LL==1LL){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2LL;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

int check(ll mid, vector <ll> vec1, vector <ll> vec2, ll k){
    for(int i = 0; i < vec1.size(); i++){
        if(vec1[i]*vec2[i] <= mid) continue;
        else{
            ll val = mid/vec2[i];
            k -= (vec1[i] - val);
        }
    }
    //cout << k << "||" << mid << endl;
    if(k >= 0) return 1;
    return 0;
}

int main() {
    double a,b,x;
     cin >> a >> b >> x;
    double h = x/(a*a);
    if(b > 2.0*h){
        double val = (2.0*a*h)/(b*b);
        //cout << val << endl;
        double ans = 90.0 - atan (val) * 180.0 / PI;
        printf("%0.8f", ans);
    } else{
        double val = a/(2.0*(b-h));
        //cout << val << endl;
        double ans = 90.0 - atan (val) * 180.0 / PI;
        printf("%0.8f", ans);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 100000;

int N;
ll A[MAX_N];
int Q;
int B, C;

int v[MAX_N + 1];

int main() {
    cin >> N;
    ll sum = 0;
    REP(i, N + 1) v[i] = 0;
    REP(i, N) {
        cin >> A[i];
        sum += A[i];
        v[A[i]]++;
    }

    cin >> Q;
    REP(i, Q) {
        cin >> B >> C;
        sum += (C -B) * v[B];
        PRINT(sum);
        v[C] += v[B];
        v[B] = 0;
    }
    return 0;
}

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

int cnt[100];

int main(void) {
	char s[100100];
	scanf("%s", s);
	int n = strlen(s);
	for(int i = 0; i < n; i++)
		cnt[s[i] - 'a']++;
	if(max(max(cnt[0], cnt[1]), cnt[2]) - min(min(cnt[0], cnt[1]), cnt[2]) <= 1) 
		puts("YES");
	else puts("NO"); 
}

Measured memory_bytes: 384
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define NumberOfOnes __builtin_popcount
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<int,int>
#define twoll pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define y1 y1922
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (int)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  int,// aq pair<int,int> shegidzlia
  null_type,
  less/*_equal*/<int>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<int, int> my_map;
inline int rin(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
inline int bin(){
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x;
}
int x,y,ans;
int m[]={0,300000,200000,100000};
int main(){FAST;xRand;
cin>>x>>y;
if(x==1&&y==1){
	cout<<300000+300000+400000<<endl;
	return 0;
}
if(x>3) x=0;
if(y>3) y=0;
ans+=m[x]+m[y];
cout<<ans<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/



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

int main()
{
	ll N, A, B;
	cin >> N >> A >> B; A -= B;
	vector<ll> h(N);
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	ll l = 0, r = 1000000000;
	while (l + 1 < r) {
		ll c = (l + r) / 2;
		ll cnt = 0;
		for (int i = 0; i < N; i++) {
			if (h[i] > B * c) {
				cnt += (h[i] - B * c + A - 1) / A;
			}
		}
		if (cnt <= c) {
			r = c;
		}
		else {
			l = c;
		}
	}
	cout << r << endl;
	return 0;
}


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

int main() {

    int H,W;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
#define SENTINEL 1000000000
#define N 500000
int count=0;

void Merge(int A[],int left,int mid,int right){

  int n1=mid - left,n2=right - mid,i,j,k;
  int L[n1+1],R[n2+1];

  for(i = 0; i < n1; i++){

    L[i] = A[left + i];
  }

  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }

  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  i = 0;
  j = 0;

  for(k = left; k < right; k++){

    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i += 1;
    }
    else{
    
      A[k] = R[j];
      j += 1;
    }
  }
}

void Merge_Sort(int A[],int left,int right){

  int mid;
  if(left + 1 < right){

    mid = (left + right) / 2;
    Merge_Sort(A,left,mid);
    Merge_Sort(A,mid,right);
    Merge(A,left,mid,right);

  }
}

int main(){

  int n,A[N],i;

  scanf("%d",&n);

  for(i = 0; i < n; i++){

    scanf("%d",&A[i]);
  }

  Merge_Sort(A,0,n);

  for(i = 0; i < n-1; i++){

    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int k; cin >> k;
    int o = (k+1)/2;
    int e = k/2;
    cout << o * e;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<vector<int>> as(h, vector<int>(w)); cin >> as;
    bool move = false;
    stringstream ss;
    int cnt = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(i == h - 1 && j == w - 1){ break; }
            int x = i & 1 ? w - 1 - j : j, y = i;
            auto out = [&](){ 
                ss << y + 1 << ' ' << x + 1 << ' ' << y + (j == w - 1) + 1 << ' ' << (j == w - 1 ? x : x + (i & 1 ? -1 : 1)) + 1 << '\n';
            };
            if(as[y][x] & 1){
                if(move){
                    move = false;
                }else{
                    move = true;
                    out();
                    cnt++;
                }
            }else{
                if(move){
                    out();
                    cnt++;
                }
            }
        }
    }
    cout << cnt << '\n';
    cout << ss.str();
}


Measured memory_bytes: 6920
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int a[6000];
bool cmp(int x , int y)
{
	return x > y;
}

int main()
{
	int n , m;
	scanf("%d %d",&n ,&m);
	for(int i = 1 ; i <= n ; i++){
		scanf("%d",&a[i]);
	}
	sort(a + 1 , a + 1 + n , cmp);
	int sum = 0;
	for(int i = 1 ; i <= m ; i++) sum += a[i];
	printf("%d\n",sum);
}

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

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> a(N);
  vector<int> b(N);
  
  for(int i = 0;i < N;i++){
    a.at(i) = i + 1;
  }
  
  int x;
  for(int i = 0;i < M * 2;i++){
    cin >> x;
    for(int j = 0;j < N;j++){
      if(a.at(j) == x){
        b.at(j) += 1;
      }
    }
  }
  
  for(int i = 0;i < N;i++){
   cout << b.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int N, C;
    cin >> N >> C;
    vvi d(C, vi(C));
    vvi c(N, vi(N));

    for (int i = 0; i < C; ++i) {
        for (int j = 0; j < C; ++j) {
            cin >> d[i][j];
        }
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> c[i][j];
            c[i][j]--;
        }
    }

    // 30*500*500 = 7500000
    vvi di(3, vi(C, 0));
    for (int k = 0; k < C; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                int idx = (i + j) % 3;
                di[idx][k] += d[c[i][j]][k];
            }
        }
    }
    int ret = 1 << 29;
    for (int i = 0; i < C; ++i) {
        for (int j = 0; j < C; ++j) {
            for (int k = 0; k < C; ++k) {
                if (i != j && j != k && k != i)
                    chmin(ret, di[0][i] + di[1][j] + di[2][k]);
            }
        }
    }
    cout << ret << "\n";

    return 0;
}

Measured memory_bytes: 1280
a,b = map(int,input().split())
if a%2 == 0:
  	a_list = [int(a/0.08) + i for i in range(13)]
else:
  	a_list = [int(a/0.08) + i for i in range(1,13)]
b_list = [int(b/0.1) + j for j in range(10)]
com = set(a_list) & set(b_list)
if len(com) == 0:
    print(-1)
elif len(com) != 0:
    if int(min(com)*0.08) != a or int(min(com)*0.1) != b:
        print(-1)
    else:
        print(min(com))

Measured memory_bytes: 9160
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var B = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var C = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var previous = -1;
        var result = 0;
        for (int i = 0; i < N; i++)
        {
            result += B[A[i] - 1];
            if (previous + 1 == A[i])
            {
                result += C[previous - 1];
            }
            previous = A[i];
        }

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int n,x,t; cin >> n >> x >> t;
    cout << (n + x - 1)/x * t << '\n';
    return 0;
}

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

int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int n1=s1.length();
	int n2=s2.length();
	int dp[n1+1][n2+1];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n1;i++)
	{
		for(int j=1;j<=n2;j++)
		{
			if(s1[i-1]==s2[j-1])
				dp[i][j]=1+dp[i-1][j-1];
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	string ans="";
	int i=n1,j=n2;
	while(i>0 && j>0)
	{
		if(s1[i-1]==s2[j-1])
		{
			ans+=s1[i-1];
			i--;j--;
		}
		else
		{
			if(dp[i-1][j]>dp[i][j-1])
			{
				i--;
			}
			else
			{
				j--;
			}
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35456
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Main {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Main() { 
		totalVertex = 0; 
	}
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		for(int x = 0; x < adjMatrix.length; x++) {
			for(int y = 0; y < adjList.get(x).size(); y++) {
				adjMatrix[x][adjList.get(x).get(y)] = 1;
			}
		}
		for(int x = 0; x < adjMatrix.length; x++) {
			for(int y = 0; y < adjMatrix[0].length; y++) {
				if(adjMatrix[x][y] == null) {
					adjMatrix[x][y] = 0;
				}
				if(y == adjMatrix[0].length-1)
					System.out.print(adjMatrix[x][y]);
				else
					System.out.print(adjMatrix[x][y]+ " ");
			}
			System.out.println("");
		}
		
	}
	
	public static void main(String args[]) {
		Main g = new Main();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU

	





Measured memory_bytes: 34456
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const string YES = "Yes";
const string NO = "No";

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool ans = false;
    REP(i, 3) if (s[i] == '7') ans = true;
    if (ans) cout << YES << '\n';
    else cout << NO << '\n';
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,l,t,x[SZ],w[SZ],p[SZ],id[SZ];
bool cmp(int a,int b) {return x[a]<x[b];}
int main()
{
	scanf("%d%d%d",&n,&l,&t); ll r=0;
	for(int i=0;i<n;++i)
	{
		scanf("%d%d",x+i,w+i);
		if(w[i]==1) p[i]=(x[i]+t)%l,r+=(x[i]+t)/l;
		else
		{
			p[i]=((x[i]-t)%l+l)%l;
			r-=(t-x[i]+l-1)/l;
		}
	}
	r=(r%n+n)%n;
	for(int i=0;i<n;++i) id[i]=i;
	sort(id,id+n,cmp); sort(p,p+n);
	for(int i=0;i<n;++i)
		printf("%d\n",p[id[(i+r)%n]]);
}


Measured memory_bytes: 9728