akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    int n; cin >> n;
    ll ans = 0;
    rep(i,1,n+1){
        ll y = n/i;
        ans += y*(y+1)*i/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep2(i,start,end) for(ll i = start; i < end; ++i)
#define dwn(i,n) for(int i = n; i >= 0; --i)
#define dwn2(i,start,end) for(ll i = start; i >= end; --i)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f;
const ll mod = 1e9 + 7;


int main(){
	int n,k;
	cin>>n;
	ll sum = 0;
	vector<pair<int,int> > v;
	rep(i,n){
		ll x;
		cin>>x;
		v.push_back({x,i});
	}
	sort(v.begin(), v.end());
	rep(i,n){
		cout<<v[i].second+1<<" ";
	}

	return 0;
}








Measured memory_bytes: 1780
using System;

public class Hello
{
    public static void Main()
    {
        var b = new int[31];
        b[0] = 1;
        for (int i = 1; i < 31; i++) b[i] = b[i - 1] * 2;
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var count = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < 31; j++)
                if (a[i] % b[j] != 0) { count += j - 1; break; }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 11744
n, y = map(int, input().split())
y //= 1000


for cnt_y in range(n + 1):
    for cnt_z in range(n + 1):
        if cnt_y + cnt_z <= n:
            cnt_x = n - (cnt_y + cnt_z)
            if cnt_x + cnt_y * 5 + cnt_z * 10 == y:
                print(cnt_z, cnt_y, cnt_x)
                exit()
else:
    print(-1, -1, -1)


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

using namespace std;

int main() {
	int n, m;
	vector<int> x(105, -99999), y(105, 99999);
	cin >> n >> m >> x[101] >> y[101];
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> y[i];
	}
	int xm = *max_element(x.begin(), x.end()), ym = *min_element(y.begin(), y.end());
	if (xm < ym) {
		cout << "No War";
	} else {
		cout << "War";
	}
	
	
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    ll a,b,c,l[10],w=1e18;
    cin>>n>>a>>b>>c;
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    sort(l,l+n);
    do{
        int m[10];
        m[0]=l[0];
        for(int i=1;i<n;i++){
            m[i]=m[i-1]+l[i];
        }
        for(int i=0;i<n-2;i++){
            ll x=i*10+abs(a-m[i]);
            for(int j=i+1;j<n-1;j++){
                ll y=(j-i-1)*10+abs(b-m[j]+m[i]);
                for(int k=j+1;k<n;k++){
                    ll z=(k-j-1)*10+abs(c-m[k]+m[j]);
                    w=min(w, x+y+z);
                }
            }
        }
    }while(next_permutation(l, l+n));
    cout<<w<<endl;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int string2int(string s) {
    return atoi(s.c_str());
}

vector<int> parseInputs(string &s) {
    vector<int> res;
    s += " ";
    int lst = 0;
    REP(i, 0, s.size()) {
        if (s[i] == ' ') {
            res.push_back(string2int(s.substr(lst, i - lst)));
            lst = i + 1;
        }
    }
    return res;
}

#include <cmath>
double calcDist(double r1, double r2) {
    return sqrt(r1 * r1 - r2 * r2);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    while (true) {
        getline(cin, s);
        if (s.size() == 0) break;
        auto res = parseInputs(s);
        int W = res[0];
        res.erase(res.begin());
        int n = res.size();
        auto dp = make_v(1 << n, n, 1e+15);
        REP(i, 0, n) {
            dp[1 << i][i] = res[i];
        }
        REP(i, 1, 1 << n) {
            REP(j, 0, n) {
                if (!((i >> j) & 1)) continue;
                REP(k, 0, n) {
                    if ((i >> k) & 1) continue;
                    double dist = calcDist(res[j] + res[k], abs(res[j] - res[k]));
                    int nxt = i | (1 << k);
                    dp[nxt][k] = min(dp[nxt][k], dp[i][j] + dist);
                }
            }
        }
        double ans = 1e+15;
        REP(i, 0, n) {
            ans = min(ans, dp[(1 << n) - 1][i] + res[i]);
        }
        ans -= 1e-6;
        cout << (ans <= W ? "OK" : "NA") << endl;
    }

    return 0;
}



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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------




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


int a[55];
int N ;

int main(){

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

    cin >> N;

    int cnt = 0;
    for ( LL i = 31 ; i < 55555; i+= 10){

        if ( prime(i) == true){

            cout << i;
            cout << " ";
            cnt++;

        }

        if( N == cnt ){ break;}
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {

    public void solve() throws IOException {
        String s = br.readLine ();
        int cnt = 0;
        for(int i = 0; i < 5; i++){
            out.print (s.charAt (i));
        }
        out.print (" ");
        for(int i = 6; i < 13; i++){
            out.print (s.charAt (i));
        }
        out.print (" ");
        for(int i = 14; i < 19; i++){
            out.print (s.charAt (i));
        }
    }


    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens ()) {
            try {
                sc = new StringTokenizer (br.readLine ());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken ();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt (nextToken ());
    }

    public boolean hasNext() {
        while (sc == null || !sc.hasMoreTokens ()) {
            try {
                String s = br.readLine ();
                if (s == null) {
                    return false;
                }
                sc = new StringTokenizer (s);
            } catch (IOException e) {
                throw new RuntimeException (e);
            }
        }
        return sc.hasMoreTokens ();
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble (nextToken ());
    }

    public long nextLong() throws IOException {
        return Long.parseLong (nextToken ());
    }

    public static void main(String[] args) throws IOException {
        Locale.setDefault (Locale.US);
        new Main ().run ();
    }

    public void run() {
        try {
            out = new PrintWriter (System.out);
            br = new BufferedReader (new InputStreamReader (System.in));
//            br = new BufferedReader (new FileReader ("triangle.in"));
//            out = new PrintWriter (new File ("triangle.out"));
            solve ();
            out.close ();
        } catch (IOException e) {
            e.printStackTrace ();
            System.exit (1);
        }
    }
}

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

int main(){
    int64_t n,k;
    cin >> n>>k;
    int64_t rest =n%k;
    if(rest==0){cout << 0<<endl;return 0;}
    if(rest==n){cout << min(n,abs(n-k))<<endl;return 0;}
    else{
    int64_t times= n/k;
     cout << min(n-times*k,(times+1)*k - n)<<endl;
     return 0;
    }
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    string ans = "YES";
    for(int i=1; i<N; i++) {
        if(A[i-1] == A[i]) {
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;
}


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

int main()
{
	string s;
	getline(cin, s);
	string::iterator it;
	int a[26] = {0};
	for(it = s.begin(); it<s.end(); it++){
		a[*it-97]++;
	}
	
	for(int i=0;i<26;i++){
		if(a[i]>1){
			cout << "no" << endl;
			return 0;
		}
	}

	cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  rep(i,N)cin >> v[i];
  int count = 0;
  rep(i,N){
    if(i+1 != v[i]) ++count;
  }
  YESNO(count == 0 || count == 2);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1e7+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;

struct edge{
	int to;
	double cost;
	edge(int _to, double _cost) :to(_to), cost(_cost){}
};

vector<edge> G[1010];
double xs, ys, xt, yt;
int n;
double d[1010];

void dijkstra(){
	REP(i, 1010)d[i] = 1e18;
	d[0] = 0;

	typedef pair<double, int> PD;
	priority_queue<PD, vector<PD>, greater<PD>> que;
	que.push(pair<double, int>(0, 0));

	while (!que.empty()){
		pair<double, int> p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(pair<double, int>(d[e.to], e.to));
			}
		}
	}
}

int main(){
	cin >> xs >> ys >> xt >> yt >> n;
	vector<double> x(1010), y(1010), r(1010);
	x[0] = xs;
	y[0] = ys;
	r[0] = 0;
	x[n + 1] = xt;
	y[n + 1] = yt;
	r[n + 1] = 0;
	FOR(i, 1, n + 1){
		cin >> x[i] >> y[i] >> r[i];
	}
	REP(i, n + 2){
		REP(j, n + 2){
			if (i == j)continue;
			G[i].push_back(
				edge(j, max(0.0, sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])) - (r[i] + r[j]))));
			//cout << i << " " << j << sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j])) - (r[i] + r[j]) << endl;
		}
	}


	dijkstra();
	printf("%.10lf\n", d[n + 1]);
}

Measured memory_bytes: 20592
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    s = rl().rstrip()
    
    que = deque(s)
    ans = 0
    while 1 < len(que):
        if que[0] == que[-1]:
            que.pop()
            que.popleft()
        elif que[0] == 'x':
            que.append('x')
            ans += 1
        elif que[-1] == 'x':
            que.appendleft('x')
            ans += 1
        else:
            print(-1)
            return
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 47088
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	string s;
	cin >> s;
	vector<int> vec;
	for(int i = 0 ; i < s.size() ; i ++){
		if(s[i] == 'A')vec.pb(1);
		else if(s[i] == 'B'){
			if(i+1 < s.size() && s[i+1] == 'C'){
				vec.pb(2);
				i ++;
			}
			else vec.pb(0);
		}
		else vec.pb(0);
	}
	ll ret = 0;
	ll cnt = 0;
	for(int i = 0 ; i < vec.size() ; i ++){
		if(vec[i] == 0){
			cnt = 0;
		}
		else if(vec[i] == 1){
			cnt ++;
		}
		else ret += cnt;
	}
	cout << ret << endl;
}

Measured memory_bytes: 1532
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>

#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    int N;
    int tmp;
    int ret = 0;;
    cin >> N;
    rep(i, N) {
        cin >> tmp;
        if((i+1) % 2 == 1 && tmp % 2 == 1)
            ++ret;
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3152
#include<cstdio>
int n, m;
int a[105], odd[105],even[105],cnt1,cnt2;
int main() {
	scanf("%d%d", &n, &m);
	int i;
	int cnt2 = 0;
	for (i = 1; i <= m; i++) {
		scanf("%d", &a[i]);
		if (a[i] % 2 == 0) even[++cnt2] = a[i];
		else odd[++cnt1] = a[i];
	}
	if (cnt1 > 2) {
		printf("Impossible");
	}
	else {
		int cnt=0, ans[100005];
		if (cnt1 == 0) {
			ans[++cnt] = 1;
			for (i = 1; i <= cnt2; i++) {
				ans[++cnt] = even[i];
			}
			ans[cnt]--;
		}
		else if (cnt1 == 1) {
			if (odd[1] > 1) ans[++cnt] = odd[1] - 1;
			ans[++cnt] = 2;
			for (i = 1; i <= cnt2; i++) {
				ans[++cnt] = even[i];
			}
			ans[cnt]--;
		}
		else {
			if (odd[1] > 1) ans[++cnt] = odd[1] - 1;
			ans[++cnt] = 2;
			for (i = 1; i <= cnt2; i++) {
				ans[++cnt] = even[i];
			}
			if (odd[2] > 1) ans[++cnt] = odd[2] - 1;
		}
		if (cnt1 >= 1) printf("%d ", odd[1]);
		for (i = 1; i <= cnt2; i++) printf("%d ",even[i]);
		if (cnt1 > 1) printf("%d", odd[2]);
		printf("\n%d\n", cnt);
		for (i = 1; i <= cnt; i++) printf("%d ", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 128
N,Q = map(int,input().split(" "))
A = [0]*N

B = [0 for j in range(N)]
for i in range(N-1):
    a,b = map(int,input().split(" "))
    A[b-1] = a-1
    
for j in range(Q):
    tmp = list(map(int,input().split(" ")))
    B[tmp[0]-1] += tmp[1]

for i in range(1,N):
        B[i] += B[A[i]]
for i in range(N):
        print(B[i],end=" ")

Measured memory_bytes: 22792
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

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

  vector<tuple<int,int,int,int>>p;

  int cnt=0;
  for(int i=0;i<H;i++){
    if(i%2!=0){
      for(int j=W-1;j>=0;j--){
          if(i==H-1&&j==0){continue;}
          if(a[i][j]%2!=0){  
            a[i][j]--;cnt++;
            if(j>0){a[i][j-1]++;p.push_back(make_tuple(i+1,j+1,i+1,j));}
            else {a[i+1][j]++;p.push_back(make_tuple(i+1,j+1,i+2,j+1));}
          }
      }
    }
    else{
      for(int j=0;j<W;j++){
          if(i==H-1&&j==W-1){continue;}
          if(a[i][j]%2!=0){
            a[i][j]--;cnt++;
            if(j<W-1){a[i][j+1]++;p.push_back(make_tuple(i+1,j+1,i+1,j+2));}
            else {a[i+1][j]++;p.push_back(make_tuple(i+1,j+1,i+2,j+1));}
          }
      }
    }
  }
  cout<<cnt<<endl;
  for(auto k:p){
    int a,b,c,d;
    tie(a,b,c,d)=k;
    cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl; 
  }
  return 0;  
}

Measured memory_bytes: 6356
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

struct Node {int p,l,r;};

const int NIL=-1;
Node T[100005];
int n,D[100005];

void print(int u) {
    printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]);

    if(T[u].p==NIL) printf("root,");
    else if(T[u].l==NIL) printf("leaf,");
    else printf("internal node,");

    printf(" [");
    
    for(int i=0,c=T[u].l;c!=NIL;i++,c=T[c].r) {
        if(i) printf(", ");
        printf("%d",c);
    }
    printf("]\n");
}

int rec(int u,int p) {
    D[u]=p;
    // 右は兄妹,左は子
    if(T[u].r!=NIL) rec(T[u].r,p);
    if(T[u].l!=NIL) rec(T[u].l,p+1);
}

int main() {
    int n,r;
    cin>>n;
    rep(i,n) T[i].p=T[i].l=T[i].r=NIL;

    rep(i,n) {
        int v,d,l;
        cin>>v>>d;
        rep(j,d) {
            int c;
            cin>>c;
            if(j==0) T[v].l=c;
            else T[l].r=c;
            l=c;
            T[c].p=v;
        }
    }
    rep(i,n) if(T[i].p==NIL) r=i;
    rec(r,0);
    rep(i,n) print(i);
    return 0;
}

Measured memory_bytes: 5828
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int buttons[] = new int[2];
		int maxCoins = 0;

		for (int i = 0; i < 2; i++) {
			buttons[0] = a;
			buttons[1] = b;

			int getCoins1 = buttons[i]--;
			int getCoins2 = 0;

			for (int j = 0; j < 2; j++) {
				if (buttons[j] > getCoins2) {
					getCoins2 = buttons[j];
				}
			}

			if (getCoins1 + getCoins2 > maxCoins) {
				maxCoins = getCoins1 + getCoins2;
			}
		}

		System.out.println(maxCoins);

		sc.close();
	}
}


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

#define int long long

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 2e5 + 5;
int a[N], b[N];
priority_queue<pair<int, int> > Q;

signed main()
{
	int n = read();
	for (int i = 1; i <= n; ++i) a[i] = read();
	for (int i = 1; i <= n; ++i) b[i] = read(), Q.push({b[i], i});
	
	int ans = 0;
	while (!Q.empty())
	{
		int i = Q.top().second;
		Q.pop();
		if (b[i] == a[i]) continue;
		
		int pre = i == 1 ? n : i - 1;
		int nxt = i == n ? 1 : i + 1;
		if (b[i] - b[pre] - b[nxt] < a[i]) return puts("-1"), 0;
		
		ans += (b[i] - a[i]) / (b[pre] + b[nxt]);
		b[i] = a[i] + (b[i] - a[i]) % (b[pre] + b[nxt]);
		if (a[i] != b[i]) Q.push({b[i], i});
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 8944
package main

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

func main() {
  stdin := bufio.NewScanner(os.Stdin)
  stdin.Scan()
  input := stdin.Text()
  hoge := strings.TrimSpace(input)
  x, _ := strconv.Atoi(hoge)
  fmt.Println(x*x*x)
}



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

using namespace std;

string S1, S2;

int longest(string a, string b) {
	int res = 0;
	int nagasa = 0;
	for (int i = 0; i < min(a.size(), b.size()); i++) {
		if (a[i] == b[i])nagasa++;
		else {
			res = max(res, nagasa);
			nagasa = 0;
		}
	}
	res = max(res, nagasa);
	return res;
}

int main() {
	while (cin >> S1 >> S2) {
		string a = S1, b = S2;
		int ans = 0;
		while (b.size()) {
			ans = max(ans, longest(S1, b));
			b.erase(b.begin());
		}
		while (a.size()) {
			ans = max(ans, longest(a, S2));
			a.erase(a.begin());
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define ll long long
#define re register
#define cs const

ll solve(ll a,ll b){
	return b%a?b/a*2*a+solve(b%a,a):(b*2-a);
}

ll n,x;

void Main(){
	std::cin>>n>>x;
	std::cout<<solve(x,n-x)+n<<"\n";
}

inline void file(){
	
}signed main(){file();Main();return 0;}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
t=A[0]
s=0
for i in range(1,len(A)):
    if t>=A[i]:
        s+=t-A[i]
    else:
        t=A[i]

print(s)


















    

                
            





    









        

    









    

        




    















    



    





    






        






    
















        


























            
    


    


    
    














    


    














Measured memory_bytes: 32176
# AOJ 0241: Quaternion Multiplication
# Python3 2018.6.25 bal4u

while True:
	n = int(input())
	if n == 0: break
	for i in range(n):
		x1, y1, z1, w1,	x2, y2, z2, w2 = map(int, input().split())
		x3 = x1*x2 - y1*y2 - z1*z2 - w1*w2
		y3 = x1*y2 + y1*x2 + z1*w2 - w1*z2
		z3 = x1*z2 - y1*w2 + z1*x2 + w1*y2
		w3 = x1*w2 + y1*z2 - z1*y2 + w1*x2
		print(x3, y3, z3, w3)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;

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

  map<pair<char, char>, int> m;
  int cnt = 0;
  for (int A = 1; A <= N; A++) {
    string sa = to_string(A);
    char ha = sa[0];
    char ta = sa[sa.size() - 1];
    if (ta == '0') continue;

    pair<char, char> pa;
    pa = make_pair(ha, ta);
    if (m[pa] != 0) {
      cnt += m[pa];
    } else {
      int tn = 0;
      if (ha == ta) {
        int n = ha - '0';
        if (n <= N) tn++;

        string s = "";
        s += ha;
        s += ha;
        n = stoi(s);
        if (n <= N) tn++;
      } else {
        string s = "";
        s += ta;
        s += ha;
        int n = stoi(s);
        if (n <= N) tn++;
      }
      for (int i = 0; i < 5; i++) {
        string zero = "";
        for (int j = 0; j < i; j++) {
          zero += "0";
        }
        for (int j = 0;; j++) {
          string s = "";
          s += ta;
          s += zero;
          s += to_string(j);
          s += ha;
          int n = stoi(s);
          if (n <= N) {
            tn++;
          } else {
            break;
          }
        }
      }
      cnt += tn;
      m[pa] = tn;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int main(){
  string s;cin >> s;int ans = 700;
  if(s[0] == 'o')ans += 100;
  if(s[1] == 'o')ans += 100;
  if(s[2] == 'o')ans += 100;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] l = new int[n];
    int[] r = new int[n];
    for(int i =0; i < n; i++){
      l[i] = sc.nextInt();
      r[i] = sc.nextInt();
    }
    int[] a = Arrays.copyOf(r, r.length);
    Arrays.sort(a);
    int max = a[a.length-1];
    List<Integer> list = likeMake(sosuMake(max));
    for(int i = 0; i < n; i++){
      Integer lt = l[i];
      Integer rt = r[i];
      int low = Collections.binarySearch(list, lt);
      int high = Collections.binarySearch(list, rt);
      if(low < 0){
        low = ~low;
      }
      if(high < 0){
        high = ~high;
      }else{
        high++;
      }
      System.out.println(high - low);
    }
  }
  
  public static List<Integer> sosuMake(int max){
    List<Integer> list = new ArrayList<>();
    list.add(2);
    for(int i = 3; i <= max; i += 2){
      for(int j = 0; j < list.size(); j++){
        int tmp = list.get(j);
        if(tmp * tmp > i){
          list.add(i);
          break;
        }else if(i % tmp == 0){
          break;
        }
      }
    }
    return list;
  }
  
  public static List<Integer> likeMake(List<Integer> sosu){
    List<Integer> list = new ArrayList<>();
    for(int num : sosu){
      if(num == 2) continue;
      Integer tmp = (num + 1) / 2;
      if(Collections.binarySearch(sosu, tmp) >= 0){
        list.add(num);
      }
    }
    return list;
  }
}

Measured memory_bytes: 103644
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] ss0 = br.readLine().trim().split(" ", 0);
		int a = Integer.parseInt(ss0[0]);
		int b = Integer.parseInt(ss0[1]);
		int c = Integer.parseInt(ss0[2]);
		
		
		for(int i=0; i<b; i++) {
			if( (a*i)%b == c ) {
				System.out.println("YES");
				return;
			}
		}
		
		
		
		
        //System.out.println(s[0].charAt(s[0].length()-1));
        System.out.println("NO");
        return;
    }
    //-----------------------------------------------------------------
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }


	//-----------------------------------------------------------------
	// 入力値確認：リスト
	static void checkInput(List l) { System.out.println(l); }
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、float型
	//   ＜使い方＞
	//     float[] f = new float[N];
	//     checkInput(f);
	static void checkInput(float[] i1) {
		StringBuilder sb = new StringBuilder();
		for(float i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、int型
	//   ＜使い方＞
	//     int[] c = new int[N];
	//     checkInput(c);
	static void checkInput(int[] i1) {
		StringBuilder sb = new StringBuilder();
		for(int i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(int[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(int[] i1: i2){
			for(int i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(long[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(long[] i1: i2){
			for(long i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}

}

Measured memory_bytes: 23124
N = int(input())
X = list(map(int, input().split()))

L = []
n = 0
for i, x in enumerate(X, 1):
    n_ = i - (x+2)//2  # xを先頭にするために落とさなきゃいけない数
    n = max(n, n_)
    L.append(n)
    n_ = i - (x+1)//2
    n = max(n, n_)
from itertools import groupby
ans = 1
mod = 10**9+7
su = 0
n_used = 0
for n_, gr in groupby(L):
    su += len(list(gr))
    ans = ans * su % mod
    su -= 1
for n_ in range(2, N-n_):
    ans = ans * n_ % mod

print(ans)


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

using namespace std;

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

  uint64_t a, b, x;
  cin >> a >> b >> x;
  uint64_t cnt;
  if (a == 0) {
    cnt = b / x + 1;
  } else {
    cnt = (b / x) - ((a - 1) / x);
  }
  cout << cnt << "\n";
}


Measured memory_bytes: 256
INTEGER N,Q
CHARACTER(100000) S
INTEGER L,R
INTEGER,ALLOCATABLE,DIMENSION(:)::CNT
INTEGER LL,memo
READ*,N,Q
READ*,S
ALLOCATE(CNT(N))
CNT=0
LL=0
DO
  memo=INDEX(S(LL:),"AC")
  IF(memo==0)EXIT
  CNT(LL+memo-1:)=CNT(LL+memo-1:)+1
  LL=LL+memo
END DO
CNT(0)=0
DO I=1,Q
  READ*,L,R
  PRINT"(I0)",CNT(R-1)-CNT(L-1)
END DO
END


Measured memory_bytes: 1572
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
 
int main(){
    int N,M,K; cin>>N>>M>>K;
     if(K%N==0){
            cout<<"Yes"<<endl;
            return 0;
        }
    if(K%M==0){
            cout<<"Yes"<<endl;
            return 0;
        }
    for(int i=0;i<=M;i++){
        for(int j=0;j<=N;j++){
            if(N*i-2*(i*j)+M*j==K){
              //cout<<i<<endl<<j<<endl;
                 cout<<"Yes"<<endl;
                 return 0;
        }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	static int F => int.Parse(Str);
	static long FL => long.Parse(Str);
	static int[] G => Strs.Select(int.Parse).ToArray();
	static decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	static long[] GL => Strs.Select(long.Parse).ToArray();
	static string Str => ReadLine();
	static string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	static int N;
	void Solve()
	{
		var I = G;
		N = I[0];
		WriteLine(ToString(Calc(Get(), Get(), I[1] - 1)));
	}
	static int[] Get() => G.Select(i => i - 1).ToArray();
	static string ToString(int[] p) => string.Join(" ", p.Select(i => i + 1));
	static int[] Calc(int[] p, int[] q, int K)
	{
		int[] ip = Inv(p), iq = Inv(q), x = Mult(q, ip, iq, p), y = Mult(ip, q, p, iq);
		switch (K % 6)
		{
			case 0: return Mult(Pow(x, K / 6), q, p, iq, Pow(y, K / 6 - 1));
			case 1: return Mult(Pow(x, K / 6), q, Pow(y, K / 6));
			case 2: return Mult(Pow(x, K / 6), q, ip, Pow(y, K / 6));
			case 3: return Mult(Pow(x, K / 6), q, ip, iq, Pow(y, K / 6));
			case 4: return Mult(Pow(x, K / 6 + 1), iq, Pow(y, K / 6));
			default: return Mult(Pow(x, K / 6 + 1), p, iq, Pow(y, K / 6));
		}
	}
	static int[] Inv(int[] a)
	{
		var c = new int[N];
		for (var i = 0; i < N; i++) c[a[i]] = i;
		return c;
	}
	static int[] Mult(int[] a, int[] b) => MakeArray(N, i => a[b[i]]);
	static int[] Mult(params int[][] a)
	{
		if (a.Length == 0) return MakeArray(N, i => i);
		var x = a[0];
		for (var i = 1; i < a.Length; i++) x = Mult(x, a[i]);
		return x;
	}
	static int[] Pow(int[] a, int b)
	{
		if (b < 0) return Inv(Pow(a, -b));
		var p = new int[N];
		var done = new bool[N];
		for (var i = 0; i < N; i++)
			if (!done[i])
			{
				done[i] = true;
				var cycle = new List<int> { i };
				var x = a[i];
				while (x != i) { cycle.Add(x); done[x] = true; x = a[x]; }
				var L = cycle.Count;
				var c = b % L;
				for (var j = 0; j < L; j++) p[cycle[j]] = cycle[(j + c) % L];
			}
		return p;
	}
}


Measured memory_bytes: 40744
s=input()
len_s=len(s)
cnt=0
for i in range(len_s):
    if i%2==0 and s[i]=="L":
        cnt+=1
    if i%2!=0 and s[i]=="R":
        cnt+=1
if cnt!=0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main(){
  COMinit();
  long X,Y;
  cin >>X>>Y;

  if((X+Y)%3!=0) cout << 0 << endl;
  else{
    long N=(X+Y)/3;
  cout << COM(N,X-N)<< endl;
  }
  
  
}

Measured memory_bytes: 23680
#include<stdio.h>

#define nMIN 2
#define nMAX 200000
#define RtMIN 1
#define RtMAX 1000000000


int main(){
int n[nMAX],Time,i,max=0,sub;

scanf("%d",&Time);
if(RtMIN<=Time&&Time<=RtMAX){
for(i=0;i<Time;i++){
scanf("%d",&n[i]);
if(RtMIN>n[i]||n[i]>RtMAX)exit(1);
}
max=n[i-1];
sub=n[i-1]-n[i-2];
for(i=Time-2;i>=0;i--){

if(max<n[i]&&i!=0){
max=n[i];
}
if(sub<max-n[i]&&n[i]!=max){
sub=max-n[i];
}
}
}
 else exit(1);

printf("%d\n",sub);
return 0;
}



Measured memory_bytes: 2564
#include <bits/stdc++.h>
using namespace std;
//cin.ignore();	// better to use 2 times getline(cin,s);
// g++ iterator.cpp -std=c++17
//cout << (A + B == C ? "YES" : "NO") << endl;
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);}

int main(void)
{
  fast();
 // 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
  // a[0]=1;
  // a[1]=1;
  // a[2]=1;
  // a[3]=2;
  // a[4]=1;
  // a[5]=2;
  // a[6]=1;
  // a[7]=5;          very huge mistake(think think)
  // a[8]=2;
  // a[9]=2;
  // a[10]=1;
  // a[11]=5;
  // a[12]=1;
  // a[13]=2;
  // a[14]=1;
  // a[15]=14;
  // a[16]=1;
  // a[17]=5;
  // a[18]=1;
  // a[19]=5;
  // a[20]=2;
  // a[21]=2;
  // a[22]=1;
  // a[23]=15;
  // a[24]=2;
  // a[25]=2;
  // a[26]=5;
  // a[27]=4;
  // a[28]=1;
  // a[29]=4;
  // a[30]=1;
  // a[31]=51;

    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int x;
    cin>>x;
    cout<<a[x-1]<<endl;

}

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

map<int,int>P{
{ 2,0},{ 3,0},{ 5,0},{ 7,0},{11,0},
{13,0},{17,0},{19,0},{23,0},{29,0},
{31,0},{37,0},{41,0},{43,0},{47,0},
{53,0},{59,0},{61,0},{67,0},{71,0},
{73,0},{79,0},{83,0},{89,0},{97,0},
};

int f(int x){
	x--;
	int c = 0;
	for(auto e:P) if(e.second>=x) c++;
	return c;
}

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

	for(int i=2; i<=N; ++i){
		for(auto e:P){
			int p = e.first;
			for(int n=i; n%p==0; n/=p) P[p]++;
		}
	}

	int ans = f(75); // {f(75)}_C_{1}
	ans += f(25) * (f(3)-1); // {f(25)}_C_{1} * {f(3)-1}_C_{1}
	ans += f(15) * (f(5)-1); // {f(15)}_C_{1} * {f(5)-1}_C_{1}
	ans += f(5)*(f(5)-1)/2 * (f(3)-2); // {f(5)}_C_{2} * {f(3)-2}_C_{1}
	cout << ans <<endl;
}

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

bool iscr[110][110];
int ans[110][110];
int main(){
	int H,W;
	char ch;
	cin>>H>>W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin>>ch;
			iscr[i][j]=(ch=='c');
			ans[i][j]=-1;
		}
	}

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(iscr[i][j]){
				ans[i][j]=0;
			}
			else if(j!=0&&ans[i][j-1]!=-1){
				ans[i][j]=ans[i][j-1]+1;
			}
			
		}
	}

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cout<<ans[i][j];
			if(j!=W-1) cout<<" ";
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;
const int MOD = 1e9 + 7;
int main() {
	int n;
	cin >> n;
	vector<int> dat(n, 0);

	FOR(i, 0, n) {
		int t;
		cin >> t;
		dat[t]++;
	}
	int cnt = 0;
	int start = (n+1) % 2;
	long long res = 1;
	for (int i = start; i <= n - 1; i += 2) {
		if (i == 0) {
			if (dat[i] != 1) {
				cout << 0 << endl;
				return 0;
			}
			cnt++;
		}
		else {
			if (dat[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
			res = (res * 2) % MOD;
			cnt += 2;
		}
	}
	if (cnt != n) {
		cout << 0 << endl;
		return 0;
	}
	cout << res << endl;
		

	return 0;
}

Measured memory_bytes: 768
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define set0(x) memset(x,0,sizeof(x))
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();int f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
int n;
vector< pair<int,int> > ans;
int main() {
	read(n);
	if(n%2 == 1){
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				if(j == n-i)continue;
				ans.push_back( make_pair(i,j));
			}
		}
	}else{
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				if(j == n+1-i)continue;
				ans.push_back( make_pair(i,j));
			}
		}
	}
	cout<<ans.size()<<endl;
	for(auto ct:ans)cout<<ct.first<<' '<<ct.second<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <assert.h>
#include <chrono>
#include <bitset>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <random>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<pll> vpll;

#ifdef OLBOEB
  mt19937 rnd(228 + 1488 + 238 + 24111997 % 322);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

void print_time() {
#ifdef OLBOEB
    cout.flush();
    cerr << "\ntime: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class L, class R> ostream& operator<<(ostream& out, map<L, R> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }



int main() {
    cout << fixed << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);


    ll n;
    cin >> n;
    vl ans(n);
    for (ll i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        --x;
        ans[x] = i;
    }

    for (ll i = 0; i < n; ++i) {
        cout << (ans[i] + 1) << " ";
    }

    print_time();
    return 0;
}




Measured memory_bytes: 1664
#include <cstdio>
#include <climits>
#include <iostream>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const ll inf = LLONG_MAX;
int n;
ll sum[maxn] = {0};
ll res = inf;
void Get(int l,int r,ll &fir,ll &sec)
{
	ll ret = inf;
	int lef = l,rig = r - 1;
	while(lef <= rig)
	{
		int mid = (lef + rig) >> 1;
		ll a = sum[mid] - sum[l - 1];
		ll b = sum[r] - sum[mid];
		if(abs(a - b) < ret)
		{
			ret = abs(a - b);
			fir = a,sec = b;
		}
		if(a <= b)
		{
			lef = mid + 1;
		}
		else
		{
			rig = mid - 1;
		}
	}
}
int main(int argc, char const *argv[])
{
	scanf("%d",&n);
	for(int i = 1;i <= n; ++i)
	{
		int a;
		scanf("%d",&a);
		sum[i] = a + sum[i - 1];
	}
	for(int i = 2;i <= n - 2; ++i)
	{
		ll a = 0,b = 0;
		Get(1,i,a,b);
		ll c = 0,d = 0;
		Get(i + 1,n,c,d);
		ll cost = max(max(a,b),max(c,d)) - min(min(a,b),min(c,d));
		res = min(res,cost);
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  int total = 0;
  for (int i = 0; i < N; i++) {
    cin >> W[i];
    total += W[i];
  }
  int acc = 0, ret;
  for (int i = 0; i < N-1; i++) {
    acc += W[i];
    int tmp = abs(total - 2 * acc);
    if (i == 0) ret = tmp;
    else ret = min(ret, tmp);
  }
  cout << ret << endl;
}


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

int main()
{
    std::string s, t;
    std::cin >> s >> t;

    int count = 0;
    for (int i = 0; i < (int)s.size(); i++)
    {
        if (s[i] != t[i])
        {
            count++;
        }
    }
    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 3920
main = do
  a:b:_ <- words <$> getLine
  let ab = read (a++b)
  putStrLn $ if isSquare ab then "Yes" else "No"

isSquare n = checkSquare n 1
checkSquare 0 _ = True
checkSquare n m
  | n < 0 = False
  | otherwise = checkSquare (n-m) (m+2)


Measured memory_bytes: 508
#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 H,W;
  cin>>H>>W;
  map<char,int > m;
  REP(i,H)REP(j,W){
    char a;
    cin>>a;
    m[a]++;
  }
  int odd=0,even=0;
  for(auto e:m){
    int a=e.second;
    switch (a%4)
    {
    case 1:
      odd++;
      break;
    case 2:
      even++;
      break;
    case 3:
      odd++;
      even++;
      break;
    default:
      break;
    }
  }
  if(odd<=1 and even<=(H%2*W)/2+(W%2*H)/2)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3636
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new java.util.Scanner(System.in);
    int alice = 0;
    int bob = 0;
    int N = Integer.parseInt(sc.nextLine());
    String[] sCards = sc.nextLine().split(" ");
    List<Integer> iCards = new ArrayList<>();
    for (int i = 0; i < N; i++) {
        iCards.add(Integer.parseInt(sCards[i]));
    }
    for (int n = 0; n < N; n++) {
      int max = 0;
      for (int c: iCards) {
        max = Math.max(max, c);
      }
      if (n == 0 || n % 2 == 0) {
        alice += max;
      } else {
        bob += max;
      }
      iCards.remove(iCards.indexOf(max));
    }
    System.out.println(alice - bob);
  }
}


Measured memory_bytes: 23764