akhauriyash/Code-Regression huggingface dataset:
import math
N, M = map(int, input().split())

if N - M == 0:
	ans = 2 * (math.factorial(N) ** 2) % (10 ** 9 + 7)
elif N - M == 1:
	ans = N * (math.factorial(M) ** 2) % (10 ** 9 + 7)
elif N - M == -1:
	ans = M * (math.factorial(N) ** 2) % (10 ** 9 + 7)
else:
	ans = 0

print(ans)

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 5e18;

void solve()
  {
   string s;
   cin>>s;
   int sz = s.size();
   if(s[sz-1] == 's')
     {
      //s[sz-1] = 'e';
      s += "es";
     }
   else
     s += 's';
   cout<<s;
  } 
int32_t main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 

   /*int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main(){
	oneforall
	ll n;
	cin>>n;
	ll w;
	cin>>w;
	ll dp[100000];
	fill(dp,dp+100000,0);
	FOR(i,1,n+1){
		ll a,b;
		cin>>a>>b;
		for(ll j = w;j>=a;j--){
			dp[j] = max(dp[j],dp[j-a]+b);
		}
	}
	ll ma = 0;
	FOR(i, 0, w + 1) { ma = max(ma, dp[i]); }
	cout<<ma;
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  std::ios_base::sync_with_stdio(false);
  int L;
  cin >> L;
  vector<tuple<int, int, int>> edge;
  for (int i = 19; i >= 2; i--) {
    edge.emplace_back(i, i + 1, 0);
    edge.emplace_back(i, i + 1, 1 << (20 - i - 1));
  }
  int now = 0;
  if ((1 << 19) & L) {
    now |= (1 << 19);
    edge.emplace_back(1, 2, 0);
    edge.emplace_back(1, 2, 1 << 18);
  }
  for (int i = 2; i <= 20; i++) {
    if ((1 << (20 - i)) & L) {
      edge.emplace_back(1, i, now);
      now |= (1 << (20 - i));
    }
  }
  cout << 20 << " " << edge.size() << endl;
  for (auto e : edge) {
    int u, v, w;
    tie(u, v, w) = e;
    cout << u << " " << v << " " << w << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll K, X;
  cin >> K >> X;

  repr(i, K - 1) {
    cout << X - i << " ";
  }

  rep(i, K) {
    if (i == 0) {
      continue;
    }
    if (i == K - 1) {
      cout << X + i;
      break;
    }
    cout << X + i << " ";
  }
  ENDL;
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8

# https://atcoder.jp/contests/abc096/tasks/abc096_d
# 16:51-


def prime_set(limit=10**5):
    """
    2020/04/10
    https://atcoder.jp/contests/abc084/tasks/abc084_d
    """

    ret = [2]
    for x in range(3, limit+1, 2):
        is_prime = True
        sqrtx = int(pow(x, 0.5))

        for p in ret:
            if p > sqrtx:
                break

            if x % p == 0:
                is_prime = False
                break

        if is_prime:
            ret.append(x)

    return ret


def main():
    N = int(input())

    primes = prime_set(55555)
    
    ans = [None] * N
    i = 0
    for p in primes:
        if p % 5 == 2:
            ans[i] = p
            if i == N-1:
                break
            i += 1

    for a in ans:
        print(a, end=" ")


main()
# print(main())


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

// ワーシャルフロイド法
// 頂点が制限された状態での最短コスト(最短経路)を計算し、dp で記録、負のコストでも解ける O(n^3)
// 参考資料：https://qiita.com/ageprocpp/items/cdf67e828e1b09316f6e#%E3%83%AF%E3%83%BC%E3%82%B7%E3%83%A3%E3%83%AB%E3%83%95%E3%83%AD%E3%82%A4%E3%83%89%E6%B3%95

// 解法参考：https://ferin-tech.hatenablog.com/entry/2017/09/17/003201

#define INF 2147483647
#define KNUM 10

int main() {
    // 
    int nVertex;
    cin >> nVertex;
    // 
    vector<vector<int>> a(nVertex, vector<int>(nVertex));
    for (int i = 0; i < nVertex; i++){
        for (int j = 0; j < nVertex; j++){    
            cin >> a.at(i).at(j);
        }
    }
    
    // ワーシャルフロイド法を逆に使う　
    vector<vector<int>> dp(nVertex, vector<int>(nVertex));
    for (int i = 0; i < nVertex; i++){
        for (int j = 0; j < nVertex; j++){
            dp[i][j] = a[i][j];
        }
    }
    
    for (int k = 0; k < nVertex; k++){
        for (int i = 0; i < nVertex; i++){
            for (int j = 0; j < nVertex; j++){
                if (i == j || j == k || k == i || dp[i][k] == -1 || dp[k][j] == -1){        // k を経由地としないと、以下の if 文で道路ない判定されてしまう
                    continue;
                }
                if (a[i][j] == dp[i][k] + dp[k][j]){                                        // 条件設定ミス dp[i][j] -> a[i][j]
                    dp[i][j] = -1;
                }
                else if(a[i][j] > dp[i][k] + dp[k][j]){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }        
    }

    // 
    long lenSum = 0; 
    for (int i = 0; i < nVertex; i++){
        for (int j = i + 1; j < nVertex; j++){
            if (dp[i][j] != -1){
                lenSum += (long)dp[i][j];
            }
        }
    }

    cout << lenSum << endl;

    return 0;
}


Measured memory_bytes: 4288
#include<bits/stdc++.h>
using namespace std;
int n;
int o=0,pc=0,qc=0;
int p[10]={};
int q[10]={};
void k(bool used[],int t[],int c){
	if(c == n){
		//for(int i=0;i<n;i++){
		//	cout<< t[i];
		//}
		//cout<<endl;
		bool y=true;
		for(int i=0;i<n;i++){
			if(t[i] != p[i]){
				y=false;
				break;
			}
		}
		if(y==true){
			pc=o;
			//cout<<o<<endl;
		}
		y=true;
		for(int i=0;i<n;i++){
			if(t[i] != q[i]){
				y=false;
				break;
			}
		}
		if(y==true){
			qc=o;
			//cout<<o<<endl;
		}
		o++;
	}else{
		for(int i=1;i<=n;i++){
			if(!used[i]){
				used[i]=true;
				t[c]=i;
				k(used,t,c+1);
				used[i]=false;
			}
		}
	}
	return;
}




int main(){
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>p[i];
	}
	for(int i=0; i<n; i++){
		cin>> q[i];
	}
	bool used[10]={};
	int t[10]={};
	k(used,t,0);
	cout<<abs(pc-qc)<<endl;
}
	
	

Measured memory_bytes: 3632
#include <cstdio>

using namespace std;

int main(){
	int N, A, B; 
	long long sum1 = 0, sum2 = 0;
	scanf("%d%d%d", &N, &A, &B);

	if(N == 1)
    {
        if(A == B)
            printf("1\n");
        else
            printf("0\n");
    }
    else 
    {
        if(A>B)
            printf("0\n");
		else{
			printf("%lld\n", (long long)(N-2)*(B-A)+1);
		}
	}
	
	return 0;
	
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F         first
#define S          second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define hell        1000000007
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 1e9
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e12+1;


using namespace std;
void solve();

void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);


/*class CompareDist
{
public:
    bool operator()(pair<ll,int> a,pair<ll,int> b) {
        if(a.F!=b.F)
        return a.F<b.F;
        else
        return a.S>b.S;
    }
};*/
int n;
ll k,a[1000001],f[1000001];
bool F(ll x);

void solve(){

  cin>>n>>k;
  forn(i,0,n)
  cin>>a[i];
  forn(i,0,n)
  cin>>f[i];

  sort(a,a+n);
  sort(f,f+n);

  ll lo=0,hi=INF;
  ll ans;
  while(lo<=hi){
    ll mid=lo+(hi-lo)/2;
    if(F(mid))
    {
      ans=mid;
      hi=mid-1;
    }
    else{
      lo=mid+1;
    }
  }
  cout<<ans;
}

bool F(ll x){
  ll sum=0;
  for(int i=0;i<n;i++){
    ll y=x/f[i];
    sum+=max(0ll,a[n-i-1]-y);
  }
  if(sum<=k)
  return true;
  else
  return false;
}

///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1)%hell)*k%hell)%hell;
  else
  return ((pw(k,x/2)%hell)*(pw(k,x/2)%hell))%hell;
}

/*void sieve(){

  for(int i=2;i<=1000000;i++){
    if(prime[i]==true){
      for(int j=i*i;j<=1000000;j+=i)
      prime[j]=false;
    }
  }

}*/


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

ll renctanble_in_histgram(vector<ll> &h){
    h.push_back(0);
    ll res = 0;
    int N = h.size();
    stack<pll> st;
    REP(i, N){
        if(st.empty()){
            st.push(make_pair(h[i], i));
        }else{
            if(st.top().first < h[i]){
                st.push(make_pair(h[i], i));
            }
            if(st.top().first > h[i]){
                pll tmp_rect = st.top();
                while(!st.empty() && st.top().first >= h[i]){
                    tmp_rect = st.top();
                    res = max(res, tmp_rect.first * (i-tmp_rect.second));
                    st.pop();
                }
                st.push(make_pair(h[i], tmp_rect.second));
            }
        }
    }
    return res;
}

int main(){
    int N;
    cin >> N;
    vector<ll> h(N);
    REP(i, N) cin >> h[i];
    printf("%lld\n", renctanble_in_histgram(h));
    return 0;
}

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

struct Task{
    int t;
    string n;
};

int main(void){
    int n,q,i,t,c,head,tail;;
    Task task[100000];
    cin>>n>>q;
    for(i=0;i<n;i++){
        cin>>task[i].n>>task[i].t;
    }
    t=c=i=head=0;
    tail=n;
    while(c!=n){
        if(head==100000){
            head=0;
        }
        if(tail==100000){
            tail=0;
        }
        
        if(task[head].t>q){
            task[tail].n=task[head].n;
            task[tail].t=task[head].t-q;
            t+=q;
            head++;
            tail++;
        }
        else if(task[head].t>0){
            t+=task[head].t;
            c++;
            cout<<task[head].n<<" "<<t<<endl;
            head++;
        }
    }
    return 0;
}


Measured memory_bytes: 7048
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long a[200020];
long long sum[200020];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i != 0) {
			sum[i] = a[i] + sum[i - 1];
		}
		else {
			sum[i] = a[i];
		}
	}
	long long co = 0;
	long long  min = 1000000000000000007;
	for (int j = 0; j < n; j++) {
		co += a[j];
		long long  k = sum[n - 1] - sum[j];
		long long ans = abs(k - co);
		if (min > ans) {
			min = ans;
		}
	}
	cout << min << endl;
	return 0;
}

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

using namespace std;

int main()
{
   int a,b;
   cin>>a>>b;
   if(a>0&&a<10&&b>0&&b<10)
   {
     cout<<a*b<<"\n";
   }
   else
     cout<<"-1\n";
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
tuple<string,int,int> A[100];
void Calc(){
	int N = rei();
	for(int i=0;i<N;i++){
		string S = res();
		int x = rei();
		A[i] = make_tuple(S,-x,i+1);
	}
	sort(A,A+N);
	for(int i=0;i<N;i++){
		cout << get<2>(A[i]) << "\n";
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
	int N;
	scanf("%d", &N);
	int* p;
	p = (int*) malloc (N * sizeof(int));
	int i;
	int j;
	for (i = 0; i < N; i++)
	{
		scanf("%d", p + i);
	}
	for (i = 0; i < N; i++)
	{
		for (j = i + 1; j < N; j++)
		{
			if (*(p + i) < *(p + j))
			{
				int t;
				t = *(p + i);
				*(p + i) = *(p + j);
				*(p + j) = t;
			}
		}
	}
	int Money = (*(p)/2);
	for (i = 1; i < N; i++)
	{
		Money = Money + *(p + i);
	}
	printf("%d\n", Money);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static int n,m=61;
	static long h=0;
	static void Main(){
		Sc sc=new Sc();
		n=sc.I;
		var a=sc.La;
		for(int i = 0;i<n;i++) {h^=a[i];}
		a=Fu(a);
		long ans=0;
		for(int i = 0;i<n;i++) {ans^=a[i];}
		Console.WriteLine("{0}",((ans&(~h))<<1)+h);
	}
	static long[] Fu(long[] b){
		for(int i = m,k=0;i>=0;i--) {
			if((h&(1L<<i))!=0){continue;}
			int p=-1;
			for(int j = k;j<n;j++) {
				if((b[j]&(1L<<i))!=0){p=j;break;}
			}
			if(p==-1){continue;}
			for(int j = 0;j<n;j++) {
				if((b[j]&(1L<<i))!=0&&j!=p){b[j]^=b[p];}
			}
			if(p!=k){b[p]^=b[k];b[k]^=b[p];b[p]^=b[k];}
			k++;
		}
		return b;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 34140
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

ll n,m;
vector<ll>x,y,z,ux,uy,uz;

ll solve(vector<ll>&a,vector<ll>&b,vector<ll>&c){
    ll res = 0;
    vector<ll>p(n);
    rep(i,n){
        p[i]=a[i]+b[i]+c[i];
    }
    ll dp[1010][1010];
    rep(i,1010)rep(j,1010)dp[i][j]=-INF;
    dp[0][0]=0;
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i<j)continue;
            chmax(dp[i+1][j],dp[i][j]);
            chmax(dp[i+1][j+1],dp[i][j]+p[i]);
        }
    }
    return dp[n][m];
}

int main(){
    cin >> n >> m;
    x.resize(n);
    y.resize(n);
    z.resize(n);
    ux.resize(n);
    uy.resize(n);
    uz.resize(n);
    rep(i,n)cin>>x[i]>>y[i]>>z[i];
    rep(i,n){
        ux[i]=-x[i];
        uy[i]=-y[i];
        uz[i]=-z[i];
    }
    ll ans = 0;
    chmax(ans,solve(x,y,z));
    chmax(ans,solve(x,y,uz));
    chmax(ans,solve(x,uy,z));
    chmax(ans,solve(ux,y,z));
    chmax(ans,solve(x,uy,uz));
    chmax(ans,solve(ux,uy,z));
    chmax(ans,solve(ux,y,uz));
    chmax(ans,solve(ux,uy,uz));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8320
#include <stdio.h>
int main(void){
  long n,m,l,i,j,k;
  scanf("%ld%ld%ld",&n,&m,&l);
  
  long a[n][m];
  long b[m][l];
  long c[100][100]={};

  for(i=0;i<n;i++){
      for(j=0;j<m;j++){
          scanf("%ld",&a[i][j]);
      }
  }
   for(i=0;i<m;i++){
      for(j=0;j<l;j++){
          scanf("%ld",&b[i][j]);
      }
  }
  for(i=0;i<n;i++){
      for(j=0;j<l;j++){
          for(k=0;k<m;k++){
              c[i][j]+=a[i][k]*b[k][j];
          }
        
          printf("%ld",c[i][j]);
            if(j!=l-1)
          printf(" ");
      }
      printf("\n");
  }
    return 0;
}

Measured memory_bytes: 2924
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b = Is()
print((b-a-1)*(b-a)//2-a)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}

	int tmp = 1;
	for (int i = 0; i < N; i++) {
		if (a.at(i) == tmp) tmp++;
	}
	if (tmp == 1) {
		cout << "-1" << endl;
	}
	else {
		cout << N - (tmp - 1) << endl;
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define P pair<int,int>
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int a[114514],b[114514];
int bin[9];
string ss[114514];
signed main(){
	ic(m) ic(n)
	rep(0,i,n)cin>>a[i]>>b[i];
	int ans=-1;
	if(n==0){
		if(m==1){
			c(0)
			return 0;
		}	
		else if(m==2){
			c(10)
			return 0;
		}
		else{
			c(100)
			return 0;
		}
	}		
	if(m==1){
		rep(0,i,n){
			if(ans!=-1&&ans!=b[i]){
				c(-1)
				return 0;
			}
			if(a[i]==1)ans=b[i];
		}
		c(ans)
		return 0;
	}
	int ans1=-1;
	int ans2=-1;
	if(m==2){
		rep(0,i,n){	
			if(a[i]==1&&ans1!=-1&&ans1!=b[i]){
				c(-1)
				return 0;
			}
			if(a[i]==2&&ans2!=-1&&ans2!=b[i]){
				c(-1)
				return 0;
			}
			if(a[i]==1)ans1=b[i];
			if(a[i]==2)ans2=b[i];
		}
		if(ans1==0){
			c(-1)
			return 0;
		}	
		if(ans1==-1)ans1=1;
		if(ans2==-1)ans2=0;
		c(ans1*10+ans2)
	}	
	ans1=-1;
	ans2=-1;
	int ans3=-1;	
	if(m==3){
		rep(0,i,n){	
			if(a[i]==1&&ans1!=-1&&ans1!=b[i]){
				c(-1)
				return 0;
			}
			if(a[i]==2&&ans2!=-1&&ans2!=b[i]){
				c(-1)
				return 0;
			}
			if(a[i]==3&&ans3!=-1&&ans2!=b[i]){
				c(-1)
				return 0;
			}	
			if(a[i]==1)ans1=b[i];
			if(a[i]==2)ans2=b[i];
			if(a[i]==3)ans3=b[i];
		}
		if(ans1==0){
			c(-1)
			return 0;
		}	
		if(ans1==-1)ans1=1;
		if(ans2==-1)ans2=0;
		if(ans3==-1)ans3=0;
		c(ans1*100+ans2*10+ans3)
	}
}				


Measured memory_bytes: 1152
#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
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    string N;

    cin >> N;

    string ans;
    if (N[0] == '7' || N[1] == '7' || N[2] == '7')
    {
        ans = "Yes";
    }
    else
    {
        ans = "No";
    }
    cout << ans << endl;
    return (0);
}

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

const int N = 1e6 + 5;

#define st first
#define nd second

typedef pair<int,int> pun;
typedef long long ll;

int ile[100];
char slo[200];

int counter[10];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i ++) {
		scanf("%s", slo);
		for (int j = 0; j < m; j ++) {
			ile[slo[j] - 'a'] ++;
		}
	}
	for (int i = 0; i <= 'z' - 'a'; i ++) {
		counter[ile[i] % 4] ++;
	}
	bool ans = true;
	counter[1] += counter[3];
	counter[2] += counter[3];
	if ((n % 2 == 0 || m % 2 == 0) && counter[1] != 0) ans = false;
	if (n % 2 == 1 && m % 2 == 1 && counter[1] != 1) ans = false;
	int ile2 = 0;
	if (n % 2 == 1) ile2 += m / 2;
	if (m % 2 == 1) {
		ile2 += n / 2;
	}
	if (ile2 < counter[2]) ans = false;
	printf("%s\n", ans? "Yes" : "No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int n;
  cin >> n;
  vector<int> ze;
  while(n--){
    int x;
    cin >> x;
    ze.push_back(x);
  }
  sort(ze.begin(), ze.end());
    cout << ze[ze.size()-1]-ze[0] << endl;
}


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

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

void solve(long long D, long long T, long long S){
  cout << (((T*S) >= D) ? YES : NO) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long D;
  scanf("%lld",&D);
  long long T;
  scanf("%lld",&T);
  long long S;
  scanf("%lld",&S);
    solve(D, T, S);
    return 0;
}


Measured memory_bytes: 3688
n=int(input())
w=input()
l=[w]
t=w[::-1][0]
for _ in range(n-1):
    w=input()
    if w[0]!=t or w in l:
        print('No')
        break
    t=w[::-1][0]
    l.append(w)
else:
    print('Yes')

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

int main(){
    int N;
    cin>>N;
    int D[N];

    rep(i,N){
        cin>>D[i];
    }

    int sum = 0;
    rep(i,N){
        for(int j=i+1;j<N;j++){
            //printf("%d,%d",i,j);
            sum += (D[i]*D[j]);
        }
    }

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

    return 0;
}

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

int solve(int n, const vector<string>& w) {
    vector<int> five(n + 1, -1), seven(n + 1, -1);
    rep(i, n) {
        for (int j = i, l = 0; j < n && l < 7; ++j) {
            l += w[j].size();
            if (l == 5) five[i] = j;
            if (l == 7) seven[i] = j;
        }
    }
    rep (i, n) {
        int k = i;
        bool ok = true;
        rep(j, 5) {
            k = (j == 0 || j == 2 ? five[k] : seven[k]) + 1;
            if (k == 0) {
                ok = false;
                break;
            }
        }
        if (ok) return i + 1;
    }
    return -1;
}

int main() {
    for (int n; cin >> n, n;) {
        vector<string> w(n);
        for (auto& e : w) cin >> e;
        cout << solve(n, w) << endl;
    }
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
string a;
void solve()
{
    int i,l=a.length(),ans=1000;
    for (i=0;i<l-2;i++)
    {
        int x=(a[i]-'0')*100+(a[i+1]-'0')*10+(a[i+2]-'0')*1;
        ans=ans<abs(x-753)?ans:abs(x-753);
    }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>a)
        solve();
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
class UnionFind():
    def __init__(self, n):
        self.n=n
        self.parents=[-1]*n # 親(uf.find()で経路圧縮して根)の番号。根の場合は-(そのグループの要素数)
    def find(self,x):
        #グループの根を返す
        if self.parents[x]<0:return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        #要素x,yのグループを併合
        x,y=self.find(x),self.find(y)
        if x==y:return
        if self.parents[x]>self.parents[y]:#要素数の大きい方をxに
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x #要素数が大きい方に併合
    def size(self,x):
        #xが属するグループの要素数
        return -self.parents[self.find(x)]
    def same(self,x,y):
        #xとyが同じグループ？
        return self.find(x)==self.find(y)
    def members(self,x):
        #xと同じグループに属する要素のリスト
        root=self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]
    def roots(self):
        #全ての根の要素のリスト
        return [i for i, x in enumerate(self.parents) if x<0]
    def group_count(self):
        #グループの数
        return len(self.roots())
    def all_group_members(self):
        #各ルート要素のグループに含まれる要素のリストの辞書
        return {r: self.members(r) for r in self.roots()}
    def all_group_members_list(self):
        #各ルート要素のグループに含まれる要素のリストのリスト
        #[[0, 2], [1, 3, 4, 5]]
        return list(self.all_group_members().values())
    def __str__(self):
        #各ルート要素のグループに含まれる要素のリストをprint()
        return '\n'.join('{}: {}'.format(r,self.members(r)) for r in self.roots())

def main():
    n, m = map(int,input().split())
    AB_union = UnionFind(n)
    for i in range(m):
        a, b = map(int,input().split())
        a -= 1
        b -= 1
        AB_union.unite(a, b)
    print(AB_union.group_count() - 1)



if __name__=='__main__':
    main()

Measured memory_bytes: 12960
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))

from collections import Counter

cA = Counter(A)
cB = Counter(B)

# 両チームに入っている文字の合計数が多い順に処理していく
# heapqで、(両方に入っている個数, Bにいる個数, その数)
# 使うごとに、1つ目、2つ目の要素を-1してもう一度heappush

import heapq as hq
q = []
hq.heapify(q)
for key,value in cB.items():
  if key in cA:
    hq.heappush(q, (-(value + cA[key]), value, key))
    if value + cA[key] > N:
      print("No")
      exit(0)
  else:
    hq.heappush(q, (-value, value, key))
print("Yes")
a_ind = 0
ans = []

while a_ind < N:
  keep = []
  while True:
    allcnt, bcnt, key = hq.heappop(q)
    allcnt *= (-1)
    if A[a_ind] == key:
      keep.append((allcnt, bcnt, key))
    else:
      ans.append(key)
      if bcnt - 1 > 0:
        hq.heappush(q, (-(allcnt - 1), bcnt - 1, key))
      break
  for k in keep:
    hq.heappush(q, k)
  a_ind += 1
    
print(*ans)

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

int main()
{
    int n,k,sum=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        int p;
        cin>>p;
        sum+=min(2*p,2*abs(p-k));
    }
    cout<<sum;
    return 0;
}



Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const ll N=2e5+5;
ll h[N],cnt,pr[N],f[N],siz[N],sum[N],Ans,ans,n,w[N],a[N],prt[N];
struct Edge{
	ll to,ne;
}e[N<<1];
struct node{
	ll x,sum,siz;
	bool operator<(const node &other)const{
		return sum*other.siz<other.sum*siz;
	}
};
void add(ll x,ll y){
	e[++cnt]=Edge{y,h[x]};
	h[x]=cnt;
}
void dfs(ll x,ll anc){
	if(a[x])prt[x]=anc,anc=x;else w[anc]++;
	for(ll i=h[x];i;i=e[i].ne)dfs(e[i].to,anc);
}
ll get(ll x){
	return (f[x]==x?x:f[x]=get(f[x]));
}
void solve(ll x){
	Ans=0;priority_queue<node>q;
	siz[0]=1;
	for(ll i=1;i<=n;i++)if(~prt[i])f[i]=i,siz[i]=1,sum[i]=w[i],q.push(node{i,w[i],1});
	while(true){
		while(!q.empty()&&q.top().siz!=siz[q.top().x])q.pop();
		if(q.empty())break;
		ll x=q.top().x;q.pop();
		if(prt[x]==-1)continue;
		Ans+=siz[get(prt[x])]*sum[x];
		f[x]=get(prt[x]);
		siz[get(prt[x])]+=siz[x];
		sum[get(prt[x])]+=sum[x];
		q.push(node{get(prt[x]),sum[get(prt[x])],siz[get(prt[x])]});
	}ans=Ans;
}
signed main(){
	n=read();add(0,1);
	for(int i=2;i<=n;i++)pr[i]=read(),add(pr[i],i);
	a[0]=1;for(ll i=1;i<=n;i++)a[i]=read();
	memset(prt,-1,sizeof(prt));dfs(0,0);prt[0]=-1;
	return solve(0),cout<<ans,signed();
}

Measured memory_bytes: 27572
while True:
    try:
        a = float(input())
        Sum = 0
        retu = 3 * a
        for i in range(10):
            if i % 2 == 0:
                retu = retu / 3
            else:
                retu = retu * 2
            Sum += retu
        print(Sum)
    except EOFError:
        break

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

long long factorial (int i) {
  if (i > 1) return i * factorial(i-1);
  return 1;
}

long long combination(int n, int k) {
    long long r = 1;
    for (long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main() {
  int n, p, a;
  vector<int> odd, even;

  cin >> n >> p;
  rep (i, n) {
    cin >> a;
    if (a % 2 == 0) even.push_back(a);
    else odd.push_back(a);
  }

  int even_size = even.size();
  int odd_size = odd.size();

  long long num_odd = 0;
  if (p == 0) {
    for (int j=0; j<=odd_size; j+=2) {
      num_odd += combination(odd_size, j);
    }
  }
  else {
    for (int j=1; j<=odd_size; j+=2) {
      /* cout << odd_size << 'C' << j << ": " << combination(odd_size, j) << endl; */
      num_odd += combination(odd_size, j);
    }
  }

  /* cout << num_odd << endl; */
  long long ans = num_odd * pow(2, even_size);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ll a[n];
	rep(i,0,n) cin >> a[i];
	sort(a,a+n);
	reverse(a,a+n);
	ll x=0;
	ll y=0,z=0;
	for(ll i=0; i<n-1; i++){
		if(a[i]==a[i+1] && x==0){
			y=a[i];
			x=1;
			i++;
			continue;
		}
		if(a[i]==a[i+1] && x==1){
			z=a[i];
			break;
		}
	}
	cout << y*z;
	return 0;
}


Measured memory_bytes: 1024
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(i64);
    let s = get!(i64);

    let mut i: i64 = 2;
    while i.pow(2) <= n {
        let mut x = 0;
        let mut j = n;
        while j != 0 {
            x += j % i;
            j /= i;
        }
        if x == s {
            println!("{}", i);
            return;
        }
        i += 1;
    }
    while i > 1 {
        i -= 1;
        let b = (n - s + i) / i;
        if b >= 2 && (n/b)%b + n%b == s {
            println!("{}", b);
            return;
        }
    }
    if n == s {
        println!("{}", n+1);
        return;
    }
    println!("-1");
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

struct Q{
    int x,y,x_,y_;
};
int main()
{
    
    int H, W;
    cin >> H >> W;
    vvi as(H,vi(W)), bs(H, vi(W));
    rep(i,H)rep(j, W){
        cin >> as[i][j];
        bs[i][j] = as[i][j];
    }
    int a=0;
    vector<Q> qs;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W-1; j++){
            if(bs[i][j]%2==0)continue;
            a++;  
            bs[i][j]--;
            bs[i][j+1]++;
            //cout << i << " " << j << " " << i  << " " << j+1 << endl;
            qs.pb({i,j,i,j+1});
        }
    }
    for(int i = 0; i < H-1; i++){
        if(bs[i][W-1]%2==0)continue;
        a++;
        bs[i][W-1]--;
        bs[i+1][W-1]++;
        qs.pb({i,W-1,i+1,W-1});
    }
    cout << a << endl;
    for(int i = 0; i < qs.size(); i++){
            Q q = qs[i];
            cout << q.x+1 << " " << q.y+1 << " " << q.x_+1 << " " << q.y_+1 << endl;


    }
    return 0;
}

Measured memory_bytes: 6132
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

double a;
int N;

signed main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        double b;
        cin >> b;
        a += 1.0/b;
    }
    printf("%.9lf\n", 1.0/a);

    return 0;
}
/*


*/

Measured memory_bytes: 256
a, b, c = map(int, input().split())
k = int(input())

for i in range(k+1):
    for j in range(k+1):
        if i+j > k:
            continue
        l = k-i-j
        A = a*(2**i)
        B = b*(2**j)
        C = c*(2**l)
        if A < B and B < C:
            print('Yes')
            exit()
else:
    print('No')


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
   string s; cin >> s;
   ll n = s.size();
   ll cnt = 0;
   REP(i, n) cnt += (s[i] == 'p');

   cout << (n / 2) - cnt << endl;
}


Measured memory_bytes: 512
# import math
# n,k = list(map(int,input().split()))
# print(math.ceil((n-1)/(k-1)))

n,m = list(map(int,input().split()))
road = {}
whole = []
for i in range(1,n+1):
    whole.append(i)
    road[i] = set()
whole = set(whole)

for i in range(m):
    a,b = list(map(int, input().split()))
    road[a].add(b)
    road[b].add(a)

taka = []
hashi = []
used = set()
no = 0
for x in road:
    l = set()
    r = set()
    l1 = []
    r1 = []
    if x in used:
        continue
    else:
        l.add(x)
        l1.append(x)
        used.add(x)
        for y in whole - road[x]:
            if y not in used:
                r.add(y)
                r1.append(y)
                used.add(y)
    while l1 != [] or r1 != []:
        while r1 != []:
            t = r1.pop()
            for y in whole-road[t]-used-l:
                l.add(y)
                l1.append(y)
                used.add(y)
        while l1 != []:
            t = l1.pop()
            for y in whole-road[t]-used-r:
                    r.add(y)
                    r1.append(y)
                    used.add(y)
    r = list(r)
    l = list(l)

    for i in range(len(l)):
        for j in range(i+1,len(l)):
            if l[j] not in road[l[i]]:
                no = 1
                break
        if no == 1:break
    if no == 1:break
    for i in range(len(r)):
        for j in range(i+1,len(r)):
            if r[j] not in road[r[i]]:
                no = 1
                break
        if no == 1:break
    if no == 1:break

    taka.append(len(l))
    hashi.append(len(r))

if no == 1:print(-1)
else:
    res = [abs(taka[i]-hashi[i]) for i in range(len(taka))]
    res.sort(reverse=-1)
    delta = 0
    for x in res:
        if delta>0:delta-=x
        else:delta+=x
    left = (n+delta)/2
    right = (n-delta)/2
    result = int((left*(left-1)+right*(right-1))/2)
    print(result)




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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO

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

    int num[n] = {-1};

    memset(num, -1, sizeof(num));

    int f = 0;
    for(int i = 0; i < m; i++) {
        int s, c;
        cin >> s >> c;

        if(num[s - 1] == -1) num[s - 1] = c;
        else if(num[s - 1] != c){
            f = 1;
            break;
        }
    }

    if(n == 1 && !f) return cout << max(0, num[0]), 0;
    for(int i = 0; i < n; i++) {
        if(!i) {
            if(num[i] == -1) num[i] = 1;
            else if(num[i] == 0) {
                f = 1;
                break;
            }
        }
    }

    if(f) return cout << -1, 0;

    for(int i = 0; i < n; i++) cout << max(0, num[i]);
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
long long an,ch=0;
bool a[200010];
bool c[200010];
int main()
{
	cin>>s;
	int l=s.size();
	for(int i=0;i<l;i++)
	if(s[i]=='B')
	{
		an+=(l-i-1);
		an-=ch;
		ch++;
	}
	cout<<an;
	return 0;
} 

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
    string mun;
    int n[3];
    int q = 3;
    cin >> mun;
    for (int i = 0; i < q; ++i) {
        n[i] = mun[i] - 48;
    }

    for (int j = 0; j < q; ++j) {
        if(n[j] == 1){
            n[j] = 9;
        } else if(n[j] == 9){
            n[j] = 1;
        }
    }

    for (int k = 0; k < q; ++k) {
        cout << n[k];
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int isprime(int);

int main()
{
  int n,s[10000],i,cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&s[i]);

  for(i=0;i<n;i++) if((isprime(s[i]))==1) cnt++;
  printf("%d\n",cnt);
  return 0;
}

int isprime(int x)
{
  int i;

  if(x==2) return 1;
  else if(x<2 || x%2==0) return 0;
  i=3;
  while(i<=sqrt(x)){
    if(x%i==0) return 0;
    i+=2;
  }
  return 1;
}

Measured memory_bytes: 632