akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <iostream> 
#include <algorithm>  
using namespace std;
typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<int, pii> viii; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef vector<vector<vl>> vvvl; 
#define MAXN  1000001
int spf[MAXN]; 
int gcd1(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd1(b, a % b);  
      
} 
void sieve() { 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
 
vector<int> getFactorization(int x) { 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL);
    int n,m,i,j,k;
    cin>>n;
    sieve();
    vector<int>a(n);
    for(i=0;i<n;i++)cin>>a[i];
    vector<int>mark(1e6+1,0);
    int flag=1;
    for(i=0;i<n&&flag;i++){
        vi p = getFactorization(a[i]);
        vector<int>::iterator ip; 
        ip = std::unique(p.begin(), p.end()); 
        p.resize(std::distance(p.begin(), ip)); 
            // unique(p.begin(),p.end());
        // for(j=0;j<p.size();j++)cout<<p[j]<<" ";cout<<endl;
        for(j=0;j<p.size()&&flag;j++){
            if(mark[p[j]]==0)mark[p[j]]=1;
            else {
                flag=0;
            }
        }
    }
    // cout<<flag<<endl;
    if(flag==1)cout<<"pairwise coprime"<<endl;
    else {
        int gcd=a[0];
        for(i=1;i<n;i++){
            gcd = gcd1(gcd, a[i]);
        }
        if(gcd==1)cout<<"setwise coprime"<<endl;
        else cout<<"not coprime"<<endl;
    }
    return 0;
}


Measured memory_bytes: 15012
#include <iostream>
#include <vector>
using namespace  std;
const int NIL = -1;

void fnMaxHeapifyUp(vector<int>& rvnPrtyHeap, int nx)
{
  int nParnt = nx / 2;
  int nLrge = nx;

  if (nParnt > 0  &&
      rvnPrtyHeap[nParnt] < rvnPrtyHeap[nLrge])
  {
    swap(rvnPrtyHeap[nParnt], rvnPrtyHeap[nLrge]);
    fnMaxHeapifyUp(rvnPrtyHeap, nParnt);
  }
}

void fnMaxHeapifyDown(vector<int>& rvnPrtyHeap, int nx)
{
  int nLeft = nx * 2;
  int nRigt = nLeft + 1;
  int nLrge = nx;

  if (nLeft < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nLeft])  
    nLrge = nLeft;
  if (nRigt < rvnPrtyHeap.size()  &&
      rvnPrtyHeap[nLrge] < rvnPrtyHeap[nRigt])
    nLrge = nRigt;

  swap(rvnPrtyHeap[nx], rvnPrtyHeap[nLrge]);
  if (nx != nLrge)
    fnMaxHeapifyDown(rvnPrtyHeap, nLrge);
}

void fnPriorityQueue(vector<int>& rvnPrtyHeap)
{
  rvnPrtyHeap.push_back(NIL);
  string sCmd;
  while (cin >> sCmd && sCmd != "end")
  {
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      rvnPrtyHeap.push_back(nNo);
      int nx = rvnPrtyHeap.size() - 1;
      fnMaxHeapifyUp(rvnPrtyHeap, nx);
    }
    else if (sCmd[0] == 'e')
    {
      if (rvnPrtyHeap[1] != NIL)
        cout << rvnPrtyHeap[1] << endl;

      rvnPrtyHeap[1] = NIL;
      fnMaxHeapifyDown(rvnPrtyHeap, 1);
    }
    else;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPrtyHeap; 

  fnPriorityQueue(vnPrtyHeap);
  return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
const int maxn = 301;
int n;
int a[4], x;
double dp[maxn][maxn][maxn];

double dfs(int x, int y, int z){
    if(dp[x][y][z] > 0) return dp[x][y][z];
    if(x == 1 && y == 0 && z == 0){
        return n;
    }
    double a = x/(double)n, b = y/(double)n, c = z/(double)n;
    dp[x][y][z] = (double) n/(x+y+z) * ( (x-1 >= 0 ? a*dfs(x-1, y, z) : 0) + (y-1 >= 0 ? b*dfs(x+1, y-1, z) : 0) + (z-1 >= 0 ? c*dfs(x, y+1, z-1) : 0) + 1);
    return dp[x][y][z];
}

int main()
{
    cin>>n;
    for(int i = 1; i <= n; i++){
        cin>>x;
        a[x]++;
    }
    printf("%.20f\n", dfs(a[1], a[2], a[3]));
}


Measured memory_bytes: 213376
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

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

		String[] arg = br.readLine().split(" ");
		long h = Long.parseLong(arg[0]);
		long w = Long.parseLong(arg[1]);
		long a = Long.parseLong(arg[2]);
		long b = Long.parseLong(arg[3]);
		Solver s = new Solver();

		System.out.print(s.solve(h, w, a, b));
	}

}

class Solver {
	long mod = 1000000007L;
	BigInteger modb = BigInteger.valueOf(mod);
	long factorials[] = new long[200001];

	void preComputeFacts() {

		int i = 200000;
		factorials[0] = 1;
		long temp = 1;
		for (int j = 1; j <= i; j++) {

			temp *= j;
			if (temp > mod) {
				temp %= mod;
			}
			factorials[j] = temp;

		}

	}

	long solve(long h, long w, long a, long b) {
		assert a <= h && b <= w : "failure";
		preComputeFacts();
		long sum = 0;
		for (long i = a + 1; i <= h; i++) {
			sum += perm(b - 1 + h - i, b - 1, h - i).multiply(perm(i - 1 + w - b - 1, i - 1, w - b - 1)).mod(modb)
					.longValue();
			if (sum > mod)
				sum %= mod;
		}
		return sum;

	}

	private BigInteger perm(long n, long a, long b) {
		return BigInteger.valueOf(factorials[(int) n])
				.multiply(BigInteger.valueOf(factorials[(int) a]).modInverse(modb))
				.multiply(BigInteger.valueOf(factorials[(int) b]).modInverse(modb)).mod(modb);
	}

}


Measured memory_bytes: 96968
#include<bits/stdc++.h>
using namespace std;
main(){
    int n , m;
    cin>>n>>m;
    float arr[n+100][m+100];
    for(int i = 0 ; i<n ; i++){
        for(int j = 0 ;  j< m ;  j++){
            cin>>arr[i][j];
        }
    }
    vector<float>v , cnt;
    for(int i = 0 ; i<n ; i++){
        for(int j = i+1 ;  j< n ;  j++){
            float sum =0;
            for(int c = 0 ; c<m ; c++){
                    float x =abs(arr[i][c] -arr[j][c]);
                    float p = powl(x , 2);
                    v.push_back(p);
                }
                for(int k = 0 ; k< v.size() ; k++){
                    sum +=v[k];
                }
                cnt.push_back(sum);
                v.clear();

        }
    }
    int ans =0;
    int sm =0;
    for(int i = 0 ; i<cnt.size() ; i++){
        float x = sqrt(cnt[i]);
        if(x - (int)x == 0) {
            ans++;
            sm +=cnt[i];
        }
    }
    cout <<ans;



}
/**


                0 0 0 1 0 2 0 3
                1 0 1 1 1 2 1 3
                2 0 2 1 2 2 2 3
                3 0 3 1 3 1 3 3
                ---------------
                1 0 1 1 1 2 1 3
                2 0 1 2 2 2 2 3
                3 0 1 3 3 3 3 3
                ---------------
                2 0 2 1 2 2 2 3
                3 0 3 1 3 2 3 3
                ---------------



**/


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s;
  int w;

  cin>>s;
  cin>>w;
  int n=s.size();

  for(int i=0;i<n;i+=w){
    cout<<s[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
	
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String m = S.substring(0,1);
		String n = S.substring(1,2);
		String l = S.substring(2,3);
	
		if(!m.equals(n) && !m.equals(l) && !l.equals(n)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}	
	}
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;

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

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

    int n;
    ll k;
    cin >> n >> k;
    vi v(n);
    for(auto &z : v)
        cin >> z,--z;
    vector<bool> visited(n, 0);

    int tren = 0;
    while(k > 0)
    {
        if(visited[tren])
            break;
        visited[tren] = 1;
        tren = v[tren];
        //cout << tren+1 << '\n';
        --k;
    }
    //cout << tren+1 << '\n';
    if(k == 0)
    {
        cout << tren+1 << '\n';
        return 0;
    }

    vi put;
    put.pb(tren);
    int ntren = v[tren];

    while(ntren != tren)
    {
        put.pb(ntren);
        ntren = v[ntren];
    }
    //for(auto z : put)
        //cout << z << ' ';

    cout << put[k%sz(put)]+1 << '\n';
}


Measured memory_bytes: 4600
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
int ans=0;
int q[55][4];
v32 A(11);

void dfs(int ind,int pre){
  if(ind==(n+1)){
    int res=0;
    forn(i,t){
      if(A[q[i][1]]-A[q[i][0]]==q[i][2]) res+=q[i][3];
    }
    ans=max(ans,res);
    return;
  }
  for(int i=pre;i<=m;i++){
    A[ind]=i;
    dfs(ind+1,i);
  }
}

int32_t main()
{
    IOS;
    cin>>n>>m>>t;
    forn(i,t){
      cin>>q[i][0]>>q[i][1]>>q[i][2]>>q[i][3];
    }
    dfs(1,1);
    cout<<ans<<ln;
}


Measured memory_bytes: 3644
h, w, d = map(int, input().split())
arr = [0] * (h * w + 1)

a = [list(map(int, input().split())) for _ in range(h)]

for i in range(h):
    for j in range(w):
        s = a[i][j]
        arr[s] = (i, j)

q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]

cnt = h * w
result = [[0] for _ in range(d)]
for i in range(d):
    l = i
    score = 0
    while l + d <= cnt:
        if l == 0:
            result[i].append(score)
            l += d
            continue
        (ux, uy) = arr[l]
        (vx, vy) = arr[l + d]
        score += (abs(vx - ux) + abs(vy - uy))
        result[i].append(score)
        l += d


for l, r in lr:
    ans = result[l % d]
    print(ans[r // d] - ans[l // d])

Measured memory_bytes: 105804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int calc(int a,int m, int pos){return a*pos%m;}
ll calc(ll a,ll b){return (a/__gcd(a,b))*b;}

int main(){
  int a1,m1,a2,m2,a3,m3;
  while(1){
  cin>>a1>>m1>>a2>>m2>>a3>>m3;
  if(!a1)break;
  ll x=1,X=1;
  ll y=1,Y=1;
  ll z=1,Z=1;
  while((x=calc(a1,m1,x))!=1)X++;
  while((y=calc(a2,m2,y))!=1)Y++;
  while((z=calc(a3,m3,z))!=1)Z++;
  cout <<calc(calc(X,Y),Z)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
//use proconio::input;
//use std::io;
use std::io::stdin;
//use std::cmp::Ordering;
//use rand::Rng;

fn main() {
    let mut num = String::new();
    stdin().read_line(&mut num).expect("Failed to read line");
    let mut result: i64 = 0;
    let num: i64 = num.trim().parse().expect(" ");
    for i in 1..num+1 {
        if (i%3!=0) && (i%5!=0) {
            result = result+i;
        }
    }
    println!("{}", result)
}

Measured memory_bytes: 2108
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.141592653589793238462643383279L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    map<string,int> mp;
    set<string> st;
    rep(i,0,n){
        string s;cin>>s;
        mp[s]++;
        st.insert(s);
    }
    vector<string> v;
    int ma=0;
    srep(itr,st){
        string e=*itr;
        if(mp[e]>ma){
            v.clear();
            v.push_back(e);
            ma=mp[e];
        }
        else if(mp[e]==ma)v.push_back(e);
    }
    sort(v.begin(),v.end());
    rep(i,0,v.size())cout<<v[i]<<endl;
}




Measured memory_bytes: 34928
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const input_lines = input.split('\n');
input_lines.forEach(line => {
  if (line.length > 0) {
    const inputs = line.split(' ');
    if ('5,5,7' === inputs.sort().toString()){
      console.log('YES');
    }else{
      console.log('NO');
  	}
  }
});

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > v(300, vector<int> (300));
vector<int> a(90001);
int main(){
    int n, m, d;
    cin>>n>>m>>d;
    map<int, pair<int, int> > mp;
    for (int i=0; i<n; i++){
        for (int j=0; j<m; j++){
            // int x; cin>>x; v[i].push_back(x);
            cin>>v[i][j];
            mp[v[i][j]] = {i+1, j+1};
        }
    }
    for (int i=1; i<=n*m; i++){
        if (i<=d){
            a[i] = 0;
            continue;
        }
        int xa = mp[i].first, xb = mp[i-d].first, ya = mp[i].second, yb = mp[i-d].second;
        a[i] = a[i-d] + abs(xa-xb) + abs(ya-yb);
    }
    int q;
    cin>>q;
    while(q--){
        int l, r;
        cin>>l>>r;
        cout<<a[r] - a[l]<<endl;
    }
}

Measured memory_bytes: 9568
n, h = map(int, input().split())
xs = [[int(x) for x in input().split()] for _ in range(n)]

a = max(x[0] for x in xs)
ys = sorted((x[1] for x in xs), reverse=True)

for i, v in enumerate(ys):
    if v <= a or h <= 0: break
    h -= v
else:
    i += 1

j = (max(h, 0) + a - 1) // a
print(i+j)

Measured memory_bytes: 22340
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;

int a(int x, int p) {
  int ret{};
  while (x%p==0) {
    ++ret;
    x /= p;
  }
  return ret;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> nd(N + 1);
  nd[1] = 1;

  vector<bool> sieve(N + 1, true);
  for (int i = 2; i < N + 1; ++i) {
    if (!sieve[i])
      continue;
    for (int j = 2 * i; j < N + 1; j += i) sieve[j] = false;
  }
  
  ll ans{1};
  for (int i = 2; i <= N; ++i) {
    if (sieve[i]) nd[i] = 2;
    else {
      for (int j = 2; j * j <= i; ++j) {
        if (i % j == 0) {
          auto x = a(i,j);
          if (x>1) nd[i] = nd[i/j] / x * (x+1);
          else nd[i] = nd[i/j] * 2;
          break;
        }
      }
    }
    //    cout << i << " " << nd[i] << endl;
    ans += i * nd[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 82716
#include <iostream>
#include <cmath>
#include <map>

using namespace std;


bool isPrime(int x) {
  if(x == 1) return false;
  if(x == 2) return true;
  if(x % 2 == 0) return false;
  int max = (int)sqrt(x);

  for(int i = 3; i <= max; i += 2) {
    if(x % i == 0) return false;
  }
  return true;
}

int main() {
  int data[10000];
  map<int, int> from;
  int index = 0;
  for(int i = 2; i <= 10000; i++) {
    if(isPrime(i)) {
      data[index] = i;
      from[i] = index;
      index++;
    }
  }

  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;

    for(int i = n; i >= 0; i--) {
      if(isPrime(i)) {
	for(int j = from[i]; j-1 >= 0; j--) {
	  if(data[j] - data[j-1] == 2) {
	    cout << data[j-1] << ' ' << data[j] << endl;
	    break;
	  }
	}
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL((a))), (a).end());} while(0)
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll H, W, K;
  cin >> H >> W >> K;
  VVll memo(W, Vll(W, 0)), dp(H+1, Vll(W));
  bit_search(bit, W-1)
  {
    bool flg = false;
    REP(i, W-2)
    {
      if (bit_check(bit, i) && bit_check(bit, i+1))
      {
        flg = true;
        break;
      }
    }
    if (flg) continue;
    REP(i, W)
    {
      bool flgl = true, flgr = true;
      ll left = i - 1, right = i;
      if (0 <= left && left < W)
      {
        flgl = false;
        if (bit_check(bit, left)) memo.at(i).at(i-1)++;
        else flgl = true;
      }
      if (0 <= right && right < W)
      {
        flgr = false;
        if (bit_check(bit, right)) memo.at(i).at(i+1)++;
        else flgr = true;
      }
      if (flgl && flgr) memo.at(i).at(i)++;
    }
  }
  REP(i, W) dp.at(1).at(i) = memo.at(0).at(i);
  REP2(i, 2, H+1)
  {
    REP(j, W)
    {
      ll sum = 0;
      REP(k, W)
      {
        sum += dp.at(i-1).at(k) * memo.at(k).at(j);
        sum %= MOD;
      }
      dp.at(i).at(j) = sum;
      dp.at(i).at(j) %= MOD;
    }
  }
  cout << dp.at(H).at(K-1) << endl;

  return 0;
}

Measured memory_bytes: 256
#木作って終わり、問題文難しい
#

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m,k = map(int, input().split())
    
    def find(par, x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par, par[x])
            return par[x]
    
    def unite(par, x,y):
        x = find(par,x)
        y = find(par,y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x,y = y,x
            par[x] += par[y]
            par[y] = x
            return True
    
    def same(par, x,y):
        return find(par, x) == find(par, y)
    
    def size(par, x):
        return -par[find(par, x)]

    friend = [-1]*n
    adj = [[] for _ in range(n)]
    for _ in range(m):
        a,b = map(int, input().split())
        adj[a-1].append(b-1)
        adj[b-1].append(a-1)
        unite(friend, a-1, b-1)

    res = []
    for i in range(n):
        p = size(friend, i) - 1 -len(adj[i])
        res.append(p)

    for _ in range(k):
        a,b = map(int, input().split())
        if same(friend, a-1, b-1):
            res[a-1] -= 1
            res[b-1] -= 1

    print(*res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 95776
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


int main(){
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  ll ans = 0;
  
  vector<ll> p(a), q(b), r(c);
  rep(i,0,a)	cin >> p.at(i);
  rep(i,0,b)	cin >> q.at(i);
  rep(i,0,c)	cin >> r.at(i);
  
  sort(all(p),greater<ll>());
  sort(all(q),greater<ll>());
  sort(all(r),greater<ll>());
  
  ll xp = 0,yp = 0,zp = 0;	//探索場所,個数
  
  while(xp + yp + zp < x + y){
    
    
    if((xp<x) && (yp<y) && (zp<c)){
      if((p.at(xp)>=q.at(yp)) && (p.at(xp)>=r.at(zp))){
        ans += p.at(xp);
        xp++;
      }else if((q.at(yp)>=p.at(xp)) && (q.at(yp)>=r.at(zp))){
        ans += q.at(yp);
        yp++;
      }else{
        ans += r.at(zp);
        zp++;
      }
    }
    else if((xp<x) && (yp<y)){
      if(p.at(xp)>=q.at(yp)){
        ans += p.at(xp);
        xp++;
      }else{
        ans += q.at(yp);
        yp++;
      }
    }
    else if((zp<c) && (yp<y)){
      if(r.at(zp)>=q.at(yp)){
        ans += r.at(zp);
        zp++;
      }else{
        ans += q.at(yp);
        yp++;
      }
    }
    else if((xp<x) && (zp<c)){
      if(p.at(xp)>=r.at(zp)){
        ans += p.at(xp);
        xp++;
      }else{
        ans += r.at(zp);
        zp++;
      }
    }
               
    
  }
  
  cout << ans << endl;
}

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



int main() {
    int n;
    cin>>n;
    vector<pair<pair<string,int>,int>> guide(n);
    vector<int> num(n);

    for(int i=0;i<n;i++){
        cin>>guide.at(i).first.first>>guide.at(i).first.second;
        guide.at(i).first.second *= -1; 
        guide.at(i).second = (i+1);
    }

    sort(guide.begin(),guide.end());

    for(int i=0;i<n;i++){
        cout<<guide.at(i).second<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(void){
    int n, x[100], y[100];
    double tmp;
    scanf("%d", &n);
    for(int i=0; i<n; i++) scanf("%d", &x[i]);
    for(int i=0; i<n; i++) scanf("%d", &y[i]);
    tmp=0;
    for(int i=0; i<n; i++) tmp+=abs(x[i]-y[i]);
    printf("%lf\n", tmp);
    tmp=0;
    for(int i=0; i<n; i++) tmp+=abs(x[i]-y[i])*abs(x[i]-y[i]);
    printf("%lf\n", sqrt(tmp));
    tmp=0;
    for(int i=0; i<n; i++) tmp+=abs(x[i]-y[i])*abs(x[i]-y[i])*abs(x[i]-y[i]);
    printf("%lf\n", cbrt(tmp));
    tmp=0;
    for(int i=0; i<n; i++) if(tmp<abs(x[i]-y[i])) tmp=abs(x[i]-y[i]);
    printf("%lf\n", tmp);
    return 0;
}


Measured memory_bytes: 2040
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#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 <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    vector<ll> v(N+1, 0);
    v[0] = 2;
    v[1] = 1;
    for(ll i = 2; i <= N; i++) {
        v[i] = v[i-1] + v[i-2];
    }
    print(v[N]);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,j,flg;
	scanf("%d",&n);
	flg=0;
	for(i=0;i<=25;i++){
		for(j=0;j<=15;j++){
			if(n-(i*4+j*7)==0){
				flg=1;
		}
	}
	}
	if(flg==0){
		printf("No\n");
	}
	if(flg==1){
		printf("Yes\n");
	} 
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n, a, b, c, d;
   cin >> n >> a >> b >> c >> d;

   cout << min((n+a-1)/a * b, (n+c-1)/c * d) << endl;

   return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
 
const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;
 
int main() {
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}

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

aatt
1
a
1
aa
3
aat
ata
taa

aatt
atat
taat
atta
ttaa

ababa
   ab o
  aba x
 abab o
ababa x
対称を見つける？
A^2はむり

ababaabb

aaaa
a4個=6
3+2+1
aaaaa
4+3+2+1
個数*個数-1)/2
*/
int main(){
  string S; cin>>S;
  ll ssz=S.size(), ans=1;
  vector<ll> A(26,0);
  for(ll i=0; i<ssz; i++){
    ll n=S[i]-'a';
    A[n]++;
  }
  ans+=(ssz*(ssz-1))/2;
  for(ll i=0; i<26; i++){
    ll m=(A[i]*(A[i]-1))/2;
    ans-=m;
  }
  cout<<ans<<endl;
}

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

constexpr ll mod = 1e9+7;

ll mod_pow(ll a, ll n, ll mod){
    ll ret = 1;
    while(n > 0){
        if(n & 1LL) ret = (ret*(a % mod))%mod;
        a = ((a%mod)*(a%mod)) % mod;
        n = n >> 1;
    }
    return ret;
}

ll mod_inv(ll a, ll mod){
    return mod_pow(a, mod-2, mod);
}

ll mod_nck(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    if(k == 0 || k == n) return 1;
    ll ret = 1;
    rep(i, 1, k+1){
        ret *= (n-i+1);
        ret %= mod;
        ret *= mod_inv(i, mod);
        ret %= mod;
    }
    return ret;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll sum = mod_pow(2, n, mod) - 1;
    sum %= mod;
    sum -= mod_nck(n, a);
    sum %= mod;
    sum -= mod_nck(n, b);
    sum %= mod;
    if(sum < 0) sum += mod;
    cout << sum << endl;
    return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll a;

    cin >> a;
    cout << a + (a*a) + (a*a*a) << endl;
}


Measured memory_bytes: 3592
package main

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

func main() {
	var n int
	fmt.Scan(&n)


	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	psStr := strings.Split(scanner.Text(), " ")
	ps := make([]int, n)
	for i, v := range psStr {
		v2, _ := strconv.Atoi(v)
		ps[i] = v2
	}
	okCnt := 0
	for i := 0; i < n - 2; i++ {
		if eval(ps[i], ps[i+1], ps[i+2]) {
			okCnt++
		}
	}
	fmt.Println(okCnt)
}

func eval(p1, p2, p3 int) bool {
	if p1 < p2 && p2 <= p3 {
		return true
	}
	if p3 < p2 && p2 <= p1 {
		return true
	}
	return false
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

int main() {
    ll n, ans=0;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    map<ll, ll> m;
    
    // -(A_j)+jを保持
    frep(i, 1, n) {
        if(m.count(-1*a[i-1]+i)) m[-1*a[i-1]+i]++;
        else m[-1*a[i-1]+i] = 1;
    }
    frep(i, 1, n) {
        m[-1*a[i-1]+i]--;
        if(m.count(a[i-1]+i)) ans += m[a[i-1]+i];
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD;
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 16368
import java.util.Scanner;


class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner (System.in);
		
		int a,b;
		
		int p;
		
		while(scan.hasNextInt())
		{
			a = scan.nextInt();
			b = scan.nextInt();
			
			p = a * b;
			
			if(p % 2 == 1)
				System.out.println("Odd");
			else
				System.out.println("Even");
		}

	}

}


Measured memory_bytes: 20564
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

struct Card
{
	char symbol;
	int number;
};


void BubbleSort(Card*, int);
void SelectionSort(Card*, int);
void ShowData(Card *, int);
bool isStable(Card*, Card*, int);


int main(int argc, char const *argv[])
{
	int n;
	cin >> n;

	Card c1[n], c2[n];

	for (int i = 0; i < n; ++i)
	{
		string str;
		cin >> str;

		c1[i].symbol = str.at(0);
		c1[i].number = (int)(str.at(1) - '0');
		c2[i].symbol = str.at(0);
		c2[i].number = (int)(str.at(1) - '0');	
	}

	BubbleSort(c1, n);
	SelectionSort(c2, n);

	ShowData(c1, n);
	printf("Stable\n");
	ShowData(c2, n);
	if (isStable(c1, c2, n)) printf("Stable\n"); else printf("Not stable\n");

	return 0;
}


void BubbleSort(Card *card, int n)
{
	Card temp;
	for (int i = 0; i < n; ++i)
	{
		for (int j = n - 1; j >= i + 1; --j)
		{
			if(card[j].number < card[j-1].number)
			{
				temp = card[j];
				card[j] = card[j-1];
				card[j-1] = temp;
			}
		}
	}
}


void SelectionSort(Card *card, int n)
{
	int min;
	for (int i = 0; i < n; ++i)
	{
		// i は配列の中の未ソート部分の先頭を表す
		min = i;
		for (int j = i; j < n; ++j)
		{
			if(card[j].number < card[min].number)
			{
				min = j;
			}
		}
		Card temp = card[min];
		card[min] = card[i];
		card[i] = temp;
	}
}


void ShowData(Card *card, int n)
{
	for (int k = 0; k < n; ++k)
	{
		if (k == n- 1)
		{
			printf("%c%d\n", card[k].symbol, card[k].number);
		}
		else
		{
			printf("%c%d ", card[k].symbol, card[k].number);
		}
	}
}

bool isStable(Card *card1, Card *card2, int n)
{
	for (int i = 0; i < n; ++i)
	{
		if(card1[i].symbol != card2[i].symbol) return false;
	}
	return true;
}

Measured memory_bytes: 1184
#pragma GCC optimize(2,3,"Ofast","unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in ll read()
	{
		ll x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
		x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
	}
	in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<=32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
#define pb push_back
const int N=1e6+5;
char s[N],t[N];
int main()
{
	int n=gs(s+1);gs(t+1);int ans=0;
	for(int i=1;i<=n;i++) ans+=s[i]!=t[i];
	cout<<ans;
	return ot(),0;
}
//Author: disangan233

Measured memory_bytes: 4000
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    let xs = read_vec_i64();
    let (a,b,c,d) = (xs[0],xs[1],xs[2],xs[3]);
    println!("{}", if ((b-a).abs() <= d && (c-b).abs() <= d) || (c-a).abs() <= d { "Yes" } else { "No" });
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec_i64<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


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

int main(void){
  string s;
  cin >> s;
  int maxlength = 0, length = 0;
  for(int i = 0; i < (int)s.length(); i++){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      length += 1;
    } else{
      maxlength = max(length, maxlength);
      length = 0;
    }
  }
  maxlength = max(length, maxlength);
  cout << maxlength << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
    static int cnt = 0;
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int n = Integer.parseInt(scan.nextLine());
	int[] s = new int[n];
	String[] inputS = scan.nextLine().split(" ");
	for (int i = 0; i < n; i++) {
	    s[i] = Integer.parseInt(inputS[i]);
	}
	mergeSort(s, 0, s.length);
	for (int i = 0; i < n - 1; i++) {
	    System.out.print(s[i] + " ");
	}
	System.out.println(s[n-1]);
	System.out.println(cnt);
    }
    public static void merge(int[] a, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	int[] L = new int[n1+1];
	int[] R = new int[n2+1];
	for (int i = 0; i < n1; i++) {
	    L[i] = a[left + i];
	}
	for (int i = 0; i < n2; i++) {
	    R[i] = a[mid + i];
	}
	L[n1] = Integer.MAX_VALUE;
	R[n2] = Integer.MAX_VALUE;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
	    cnt++;
	    if (L[i] <= R[j]) {
		a[k] = L[i];
		i = i + 1;
	    } else {
		a[k] = R[j];
		j = j + 1;
	    }
	}
    }
    public static void mergeSort(int[] a, int left, int right) {
	if (left + 1 < right) {
	    int mid = (left + right) / 2;
	    mergeSort(a, left, mid);
	    mergeSort(a, mid, right);
	    merge(a, left, mid, right);
	}
    }
}

Measured memory_bytes: 173292
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    char a, b;
    cin >> a >> b;
    if (a == 'D')
    {
        if (b == 'D')
        {
            cout << "H\n";
        }
        else
        {
            cout << "D\n";
        }
    }

    else
    {
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll tb[105][105], rsum[105], csum[105];

int main() {
    init();
    ll r,c;
    cin >> r >> c;
    rep(i, r) rep(j, c) cin >> tb[i][j];

    rep(i, r) rep(j, c) rsum[i] += tb[i][j], csum[j] += tb[i][j];

    ll sum = accumulate(rsum, rsum + r, 0ll);

    rep(i,r){
        rep(j, c) cout << tb[i][j] << " ";
        cout << rsum[i] << endl;
    }
    rep(j, c) cout << csum[j] << " ";
    cout << sum << endl;
}


Measured memory_bytes: 3156
using System;

namespace B___Lucas_Number
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var l = new long[87];
            l[0] = 2;
            l[1] = 1;
            for(var i=2; i<=86; i++)
            {
                l[i] = l[i - 1] + l[i - 2];
            }
            Console.WriteLine(l[n]);
        }
    }
}

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

using namespace std;

typedef long long ll;

#define MOD (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);



ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll pow(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }

return ans;
}



int main()
{fast


ll n;cin>>n;

ll f=0,t=0;

ll temp;

for(int i=1;i<=n;i++)
{
  cin>>temp;
  if(temp%4==0)f++;
  else if(temp%2==0)t++;
}

if(2*f+1>=n)
  {
    cout<<"Yes"<<"\n";
    return 0;
  }

else
{
if(2*f+t>=n)
{
  cout<<"Yes"<<"\n";
 
}  
 else cout<<"No"<<"\n";
}


 return 0;

}


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

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) ((x) & -(x))
#define BIT(a , b) (((a)>>(b)) & 1)

const ll MAXN=2e3+10;
const ll Mod=924844033;

ll dp[MAXN][MAXN];
ll ps[MAXN][MAXN];

ll a[MAXN];
ll b[MAXN];
ll d[MAXN];
ll e[MAXN];
ll tmp[MAXN];
ll rev[MAXN];
ll fact[MAXN];

ll pw(ll x , ll n)
{
    if (n==0)
    {
        return 1;
    }

    ll w=pw(x , n/2);
    w*=w;
    w%=Mod;

    if (n&1)
    {
        w*=x;
        w%=Mod;
    }

    return w;
}

ll c(ll n , ll k)
{
    return (fact[n]*((rev[k]*rev[n-k])%Mod))%Mod;
}

void mult(ll x[MAXN] , ll y[MAXN] , ll z[MAXN])
{
    for(int i=0;i<MAXN;i++)
    {
        tmp[i]=0;

        for(int j=0;j<=i;j++)
        {
            tmp[i]+=y[j]*z[i-j];
            tmp[i]%=Mod;
        }
    }

    for(int i=0;i<MAXN;i++)
    {
        x[i]=tmp[i];
    }
}

void poly_pw(ll a[MAXN] , ll b[MAXN] , ll k)
{
    if (k==0)
    {
        return;
    }

    poly_pw(a , b , k/2);
    mult(b , b , b);

    if (k&1)
    {
        mult(b , a , b);
    }
}

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

	int n , k;
	cin>>n>>k;

	fact[0]=1;

	for(int i=1;i<MAXN;i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=Mod;
    }

    rev[MAXN-1]=pw(fact[MAXN-1] , Mod-2);

    for(int i=MAXN-2;i>=0;i--)
    {
        rev[i]=rev[i+1]*(i+1);
        rev[i]%=Mod;
    }

    dp[0][0]=1;
    dp[1][0]=1;

    ps[0][0]=1;
    ps[1][0]=1;
    ps[1][1]=1;

	for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            dp[i][j]=dp[i-1][j]+(j-2>=0 ? dp[i-2][j-2] : 0)+(i-j-1>=0 ? 2*ps[i-2][i-j-1] : 0);
            dp[i][j]%=Mod;

            ps[i][i-j]=dp[i][j]+ps[i-1][i-j];
            ps[i][i-j]%=Mod;
        }
    }

    for(int i=0;i<MAXN;i++)
    {
        a[i]=dp[n/k][i];
        d[i]=dp[(n/k)+1][i];
    }

    b[0]=1;
    e[0]=1;

    poly_pw(a , b , k-(n%k));
    poly_pw(d , e , n%k);
    mult(b , b , e);

    for(int i=n;i>=0;i--)
    {
        b[i]*=fact[n-i];

        for(int j=i+1;j<=n;j++)
        {
            b[i]+=Mod-((c(j , i)*b[j])%Mod);
            b[i]%=Mod;
        }
    }

    cout<<b[0];
}


Measured memory_bytes: 61952
#include<iostream>
using namespace std;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<b)swap(a,b);
    cout<<gcd(a,b)<<endl;
    return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,T;
    cin >> N >> T;
    int cnt = 0,mini = INF, maxd = 0;
    rep(i,0,N){
        int x;
        cin >> x;
        mini = min(mini, x);
        if(maxd < x - mini){
            maxd = x - mini;
            cnt = 1;
        }else if(maxd == x - mini)cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
N, Y = gets.chomp.split(' ').map(&:to_i)

N.downto(0) do |x|
  next if 10000 * x > Y
  (N-x).downto(0) do |y|
    next if 10000 * x + 5000 * y > Y
    if Y == 10000 * x + 5000 * y + 1000 * (N - x - y)
      puts "#{x} #{y} #{N - x - y}"
      exit
    end
  end
end
puts '-1 -1 -1'


Measured memory_bytes: 3836
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
   char str[32] = { NULL };
   char str2[32] = { NULL };
   scanf( "%s", str );
   scanf( "%s", str2 );

   int a = atoi( str );
   int b = atoi( str2 );
   
   if( a > b )
      printf( "a > b\n" );
   else if( a < b )
      printf( "a < b\n" );
   else if( a == b )
      printf( "a == b\n" );

  return 0;
}


Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll A,B;
    string S;
    cin >> S;
    cout << S.substr(0,3) << endl;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <math.h>

int main(void)
{
	int number;
	double x1,y1,r1,x2,y2,r2,d;
	scanf("%d",&number);
	while(number--)
	{
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&r1,&x2,&y2,&r2);

		d = sqrt((x2-x1) * (x2 - x1) + (y2-y1) * (y2 - y1));

		if(d > r1  + r2 )
		{
			printf("0\n");
		}
		else if(d < r1 - r2)
		{
			printf("2\n");
		}
		else if(d < r2- r1)
		{
			printf("-2\n");
		}
		else
		{
			printf("1\n");
		}
	}
	return 0;
}

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

int main(){
    int a;
    scanf("%d", &a);
    switch (a % 10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        printf("hon");
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        printf("pon");
        break;
    case 3:
        printf("bon");
        break;
    }
}


Measured memory_bytes: 3792
N=int(input())
S=list(map(int,input().split()))
S.sort()
p=[S[-1]]
r=S[:-1]

for i in range(N):
    nr = []
    for p_ in p[::-1]:
        while r:
            nr.append(r.pop())
            if nr[-1]<p_:
                p.append(nr.pop(-1))
                break
    p.sort()
    r+=nr[::-1]

print("Yes" if len(r)==0 else "No")

Measured memory_bytes: 34676
#include<iostream>
#include <algorithm>
#include <string.h>
#include <vector>
using namespace std;
int main(){
	long long A1,B1,C1,A2,B2,C2;
	int t=0;
	cin>>A1>>B1>>C1;
	while(1){
		if(A1%2==1||B1%2==1||C1%2==1)break;
		A2=(B1+C1)/2;
		B2=(A1+C1)/2;
		C2=(A1+B1)/2;
		if(A1==A2&&B1==B2&&C1==C2){
			t=-1;
			break;
		}
		A1=A2;
		B1=B2;
		C1=C2;
		++t;
	}
	cout<<t<<endl;
	return 0;
}


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


using namespace std;

const int INF = 1000000;

int main(){
    string s;
    cin >> s;

    if(s=="abc")cout << "Yes";
    else if(s=="acb")cout << "Yes";
    else if(s=="bac")cout << "Yes";
    else if(s=="bca")cout << "Yes";
    else if(s=="cab")cout << "Yes";
    else if(s=="cba")cout << "Yes";
    else cout << "No";

}


Measured memory_bytes: 256