akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;

//1年1月1日を1日目と数えたとき、何日目かどうか
int getTotalDay(int year, int month, int date){
	int nomal = 20*5+19*5;//大の月と小の月(3n+1,3n+2)1年間の日にち
	int abnomal = 20*10;//すべて大の月(3n)

	//year年だけをぬかして考える
	int result;
	if(year%3==0){
		result = nomal*(year/3)*2 + abnomal*(year/3 - 1);
	}else if(year%3==1){
		result = nomal*(year/3)*2 + abnomal*(year/3);
	}else if(year%3==2){
		result = nomal*((year/3)*2 + 1) + abnomal*(year/3);
	}
	//月の処理
	if(year%3==0){//すべて大の月
		result +=(month-1)*20;
	}else{//大の月、小の月の交互
		if(month%2==0){
			result += (month/2)*20 + (month/2-1)*19;
		}else if(month%2==1){
			result += (month/2)*20 + (month/2)*19;
		}
	}
	//日にちの処理
	result += date;
	return result;
}

int main(){
	int n;
	cin >> n;
	int mday = getTotalDay(1000,1,1);//ミレニアム(1000年1月1日)
	for(int i=0;i<n;i++){
		int year, month, date;
		cin >> year >> month >> date;
		int bday = getTotalDay(year,month,date);
		cout << mday - bday << endl;
	}
	return 0;
}

/*
方針
1年1月1日を1日目として、考えていく。
*/

Measured memory_bytes: 1160
n=int(input())
ds=[]
for b in range(4):
    ds.append([])
    for f in range(3):
        ds[b].append([])
        for r in range(10):
            ds[b][f].append(0)
for i in range(n):
    txt=input().split()
    for num,v in enumerate(txt):
        txt[num]=int(v)
    ds[txt[0]-1][txt[1]-1][txt[2]-1]+=txt[3]
for b in range(4):
    if b>=1:
        print('#'*20)
    for f in range(3):
        txt=''
        for r in range(10):
            txt+=' '+str(ds[b][f][r])
        print(txt)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<int> w(n);
  int sum = 0;
  for(int i = 0;i < n;i++){
    cin >> w[i];
    sum += w[i];
  }
  int ret = sum;
  int cur = 0;
  for(int i = 0;i < n;i++){
    cur += w[i];
    ret = min(ret,abs(sum - 2*cur));
  }
  cout << ret << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N+2);
  A.at(0)=0;
  A.at(N+1)=0;
  int64_t sum=0;
  for(int i=1;i<=N;i++){
    cin >> A.at(i);
    sum+=abs(A.at(i)-A.at(i-1));
  }
  sum+=abs(A.at(N)-A.at(N+1));
  vector<int64_t> ans;
  for(int i=1;i<=N;i++){
    ans.push_back(sum-abs(A.at(i)-A.at(i-1))-abs(A.at(i+1)-A.at(i))+abs(A.at(i+1)-A.at(i-1)));
  }
  for(int i=0;i<ans.size();i++){
    cout << ans.at(i) << endl;
  }
  return 0;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
int main(){
  string X, Y;
  cin >> X >> Y;
  if (X<Y){
    cout << "<" << endl;
  }
  else if (X>Y){
    cout << ">" << endl;
  }
  else{
    cout << "=" << endl;
  }
}


Measured memory_bytes: 256
(function main(){
  let lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n");
  let [n, k] = lines.shift().split(' ').map(Number);
  let w = lines.map(Number);

  const canAllStack = (p) => {
    let cnt = 0;
    for (let i = 0; i < k; i++)
      for (let sum = 0; sum + w[cnt] <= p;){
        sum += w[cnt++]
        if (cnt === n) return n;
      }
    return cnt;
  };

  let p = Math.floor(w.reduce((a, b) => a + b) / k - 1);
  while (canAllStack(++p) !== n);
  console.log(p);
})();



Measured memory_bytes: 32404
s = input().split(" ")
s = [int(s[i]) for i in range(len(s))]
R = s[0]
G = s[1]
B = s[2]
N = s[3]

# r + g + b = n
# r = 0 , 1 ,2, ... n
# r = k(0 <= k <= R)の時　g + b = n - k 
# g = l(0 <= l <= min(n - k , G))の時 b = n - k - l(１通り)
#よって、sum(n - k + 1)
rst = 0
for k in range(int(N / R) + 1) : 
    for l in range(int( (N - k*R) / G) + 1) : 
        if (N - k * R - l * G) % B == 0  : 
            rst += 1
print(rst) 

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

template<typename T>
struct BIT {
	int n;
	vector<T> bit;
	BIT() :n(0) {}
	BIT(int _n) :n(_n) { bit = vector<T>(n + 1); }
	void add1(int idx, T val) {
		for (int i = idx; i <= n; i += i & -i) bit[i] += val;
	}
	T sum1(int idx) {
		T res = 0;
		for (int i = idx; i > 0; i -= i & -i) res += bit[i];
		return res;
	}
	//0-indexed
	void add(int idx, T val) { add1(idx + 1, val); }
	//0-indexed [left, right)
	T sum(int left, int right) { return sum1(right) - sum1(left); }

	int lower_bound(T x) {
		int res = 0;
		int k = 1;
		while (2 * k <= n) k <<= 1;
		for (; k > 0; k >>= 1) {
			if (res + k <= n and bit[res + k] < x) {
				x -= bit[res + k];
				res += k;
			}
		}
		return res;
	}
};


template<typename T>
struct RangeAddBIT {
	int n;
	BIT<T> bit[2];
	RangeAddBIT() :n(0) {}
	RangeAddBIT(int _n) :n(_n) { bit[0] = bit[1] = BIT<T>(n); }

	//0-indexed, [left, right)
	void add(int left, int right, T val) {
		bit[0].add(left, -val * (left - 1));
		bit[0].add(right, val * (right - 1));
		bit[1].add(left, val);
		bit[1].add(right, -val);
	}
	
	//0-indexed, [left, right)
	T sum(int left, int right) {
		T suml = bit[0].sum(0, left) + bit[1].sum(0, left) * (left - 1);
		T sumr = bit[0].sum(0, right) + bit[1].sum(0, right) * (right - 1);
		return sumr - suml;
	}
};

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

	int n, kkt; scanf("%d %d", &n, &kkt);
	RangeAddBIT<ll> bit(n);
	while (kkt--) {
		int t; scanf("%d", &t);
		if (t == 0) {
			int s, t, x; scanf("%d %d %d", &s, &t, &x);
			s--;
			bit.add(s, t, x);
		}
		else {
			int s, t; scanf("%d %d", &s, &t);
			s--;
			printf("%lld\n", bit.sum(s, t));
		}
	}
	return 0;
}



Measured memory_bytes: 4448
#include <stdio.h>
#include <string.h>

int main() {
  char s[101];

  scanf("%s", s);

  int n = strlen(s);
  int cnt = 0;
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - i - 1]) {
      cnt++;
    }
  }

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

Measured memory_bytes: 128
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: 高橋君とカード / Tak and Cards
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;
const int MAX_X = 50;

/* typedef */

typedef long long ll;

/* global variables */

int xs[MAX_N];
ll dp[MAX_N + 1][MAX_N * MAX_X + 1];

/* subroutines */

/* main */

int main() {
  int n, a;
  cin >> n >> a;
  int na = n * a;

  for (int i = 0; i < n; i++) cin >> xs[i];

  dp[0][0] = 1;

  for (int i = 0; i < n; i++) {
    int &xi = xs[i];
    for (int j = n - 1; j >= 0; j--)
      for (int k = 0; k + xi <= na; k++)
	dp[j + 1][k + xi] += dp[j][k];
  }

  ll sum = 0;
  for (int i = 1; i <= n; i++) sum += dp[i][i * a];

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int a,b; cin >> a >> b;
    if(a == 1) a = 14;
    if(b == 1) b = 14;

    if(a == b) cout << "Draw" << endl;
    else if(a > b) cout << "Alice" << endl;
    else cout << "Bob" << endl;

}

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

typedef long long ll;
typedef vector<int> vi;
#define MOD 1000000007LL
#define BITS 60

int main()
{
    int N; cin >>N;
    vi popcnt(BITS, 0);

    for (int i = 0; i < N; i++) {
        ll a; cin >> a;
        for (int b = 0; b < BITS; b++) {
            if (a & (1LL<<b)) popcnt[b]++;
        }
    }

    ll ans = 0;
    for (int b = 0; b < BITS; b++) {
        ans += (ll)popcnt[b] * (N - popcnt[b]) % MOD * ((1LL<<b) % MOD) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
int main() {
	long long int a[3];
	std::cin >> a[0] >> a[1];
	int c = a[0], b = a[1];
	while (a[2] != 0) {
		a[2] = a[0] % a[1];
		a[0] = a[1];
		a[1] = a[2];
	}
	long long int ans = c / a[0] * b;
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
A, B = map(int,input().split())
 
sum_A = int(A/0.08)
sum_B = int(B/0.10)

flag = True
for i in range(1010):
    if A == int(i * 0.08) and B == int(i * 0.10):
        print(i)
        flag = False
        break
    else:
        #print(-1)
        continue
if flag:
    print(-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
//const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
int main(){
    string s;
    std::cin >> s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7')std::cout << Yes << std::endl;
    else std::cout << No << std::endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<utility>
using namespace std;

class P{
public:
  string word;
  int edge;
  P(string a, int b){
    word = a;
    edge = b;
  }
  bool operator < (const P &a) const { return word > a.word; }
};

int main(){
  int n,a,s,g;
  int from[400],to[400];
  string spell[400];
  string ans[250][40];
  int prvx[250][40],prvy[250][40];

  while(1){
    cin >> n >> a >> s >> g;
    if(!n && !a && !s && !g)break;

    for(int i=0;i<a;i++)cin >> from[i] >> to[i] >> spell[i];
    for(int i=0;i<250;i++){
      for(int j=0;j<n;j++){
	ans[i][j] = "NO";
	prvx[i][j] = -1;
	prvy[i][j] = -1;
      }
    }
    ans[0][s] = "";

    priority_queue< P > str;
    for(int i=0;i<a;i++){
      if(from[i] == s)str.push(P(spell[i],i));
    }
    bool f = false;
    while(str.size()){
      P hoge = str.top();
      string tmp = hoge.word;
      int num = hoge.edge;

      if(ans[tmp.size()][to[num]] == "NO"){
	ans[tmp.size()][to[num]] = tmp;
	prvx[tmp.size()][to[num]] = tmp.size() - spell[num].size();
	prvy[tmp.size()][to[num]] = from[num];
	if(to[num] == g)break;
	for(int i=0;i<a;i++){
	  int sum = tmp.size() + spell[i].size();
	  if(from[i] == to[num] && sum < 250 && ans[sum][to[i]] == "NO")str.push(P(tmp+spell[i],i));
	}
      }
      str.pop();
    }
    
    if(f)cout << "NO" << endl;
    else{
    string res = "NO";
    int posx = -1, posy = -1;
    for(int i=0;i<250;i++){
      if(res == "NO"){
	res = ans[i][g];
	posx = i;
	posy = g;
      }else if(ans[i][g] != "NO" && res > ans[i][g]){
	res = ans[i][g];
	posx = i;
	posy = g;
      }
    }

    if(posx>=0){
      vector<int> visit;
      int x = posx, y = posy;
      bool loop = false;
      visit.push_back(y);
      while(x>=0 && y>=0){
	int t = prvx[x][y];
	y = prvy[x][y];
	x = t;

	for(int i=0;i<(int)visit.size();i++){;
	  if(visit[i] == y)loop = true;
	}
	if(loop)break;
	visit.push_back(y);
      }
      if(loop)res = "NO";
    }
    cout << res << endl;
    }
  }
}

Measured memory_bytes: 10000
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    long long n;
    long long b[11];
    b[0] = 1;
    for(int i = 1; i <= 10; i++){
    	b[i] = b[i - 1] * 10;
    }
    while(true){
    	cin >> n;
    	if(n == -1)break;
    	long long ans = 0;
    	int i = 0;
    	while(n != 0){
    		ans += (n % 4) * b[i];
    		n /= 4;
    		i++;
    	}
    	cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

int v[100009];
vector<int> adj[100009];

LL dp(int x,int p){
	LL maxv=-1;
	LL sum=0;
	for(int i:adj[x]){
		if(i==p)continue;
		LL nv=dp(i,x);sum+=nv;
		maxv=max(maxv,nv);
	}
	if(maxv==-1){
		return v[x];
	}
	LL maxp=0;
	if(2*maxv>=sum){maxp=sum-maxv;}
	else{maxp=sum/2;}
	LL pn=sum-v[x];
	if(pn<0||maxp<pn){
		printf("NO");exit(0);
	}
	return sum-pn*2;
}

int main(){
	DRI(n);
	REP(i,n)RI(v[i]);
	REP(i,n-1){
		DRII(a,b);a--;b--;
		adj[a].PB(b);adj[b].PB(a);
	}
	if(n==2){
		if(v[0]==v[1])printf("YES");
		else printf("NO");
		return 0;
	}
	int r=0;
	REP(i,n){
		if(SZ(adj[i])>1)r=i;
	}
	if(dp(r,-1)==0)printf("YES");
	else printf("NO");
}


Measured memory_bytes: 13184
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		long n = s.nextInt(); // intだとオーバーフローする
		System.out.println(fact(n));
	}


	static long fact(long n) {
		// n! = 1          if (n==0)
		//    = n * (n-1)! otherwise
		// 3! = 3 * 2! = 3 * 2 * 1! = 3 * 2 * 1 * 0! = 3 * 2 * 1 * 1
		if (n == 0)
			return 1;
		else
			return n * fact(n - 1);
	}


	static long factorial(long n) {
		long p = 1;
		for(int i=1; i<=n; i++)
			p *= i;
		return p;
	}
}

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

int main(){
	int n, t = 0;
	cin >> n;
	vector<long> h(n);
	for(int i = 0; i< n; i++) {
      	cin >> h[i];
	}
  	for(int i = 1; i < n; i++) {
    	if(h[i] >= h[i-1]) {
       		continue;
        } else {
          	t += h[i-1] -h[i];
        }
    }
  	t += h[n-1];
  	cout << t << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <set>
#include <algorithm>
using namespace std;
const int maxd = 2e5+10;
typedef pair<int,int> P;
void solve()
{
    long long n;scanf("%lld",&n);
    if(n % 2 == 1) printf("0\n");
    else
    {
        long long ans = 0ll,now = 10ll;
        while(now <= n) ans+= n/now,now *= 5ll;
        printf("%lld\n",ans);
    }
}
int main()
{
//    freopen("a.in","r",stdin);
//    freopen("k.out","w",stdout);
    //int t;scanf("%d",t);
    int t = 1;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 128
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

base = 100000 :: Int
newtype Mod = Mod {getMod :: Int} deriving (Show, Eq, Ord)
newMod x = Mod (mod x base)
instance Num Mod where
  Mod x + Mod y = newMod (x + y)
  Mod x * Mod y = newMod (x * y)
  abs = id
  negate (Mod x) = newMod (base - x)
  signum (Mod 0) = Mod 0
  signum _ = Mod 1
  fromInteger x = newMod (fromInteger x)
modZero = Mod 0
modOne = Mod 1

data From = West | South | WestRest | SouthRest deriving (Eq, Show, Ord, Ix)
froms = [West, South, WestRest, SouthRest]

f :: Int -> Int -> Int
f w h = runST $ do
    arr <- newArray ((1,1,West),(w,h,SouthRest)) modZero :: ST s (STArray s (Int,Int,From) Mod)
    forM_ [2..w] $ \x -> writeArray arr (x,1,West) modOne
    forM_ [2..h] $ \y -> writeArray arr (1,y,South) modOne
    forM_ [(x,y) | x <- [2..w], y <- [2..h]] $ \(x,y) -> do
        readArray arr (x-1,y,South) >>= writeArray arr (x,y,WestRest)
        (+) <$> readArray arr (x-1,y,West) <*> readArray arr (x-1,y,WestRest) >>= writeArray arr (x,y,West)
        readArray arr (x,y-1,West) >>= writeArray arr (x,y,SouthRest)
        (+) <$> readArray arr (x,y-1,South) <*> readArray arr (x,y-1,SouthRest) >>= writeArray arr (x,y,South)
    fmap (getMod . sum) $ sequence [readArray arr (w,h,d) | d <- froms]

main = takeWhile (any (/=0)) . map (map readInt . words) . lines <$> getContents >>= mapM_ (print . apply2 f)

Measured memory_bytes: 6952
a,b=map(int,input().split())
c=[]
for i in range(a):
    c.append(list(map(int,input().split())))
#print(c)
d=[]
for i in range(b):
    d.append(int(input()))
for i in range(a):
    sum=0
    for j in range(b):
        sum+=c[i][j]*d[j]
    print(sum)


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

using namespace std;

const int vy[] = {0, 1, 0, -1}, vx[] = {1, 0, -1, 0};

int N;
string S[128];

void dfs(int y, int x)
{
  S[y][x] = 'x';
  for(int i = 0; i < 4; i++) {
    int ny = y + vy[i], nx = x + vx[i];
    if(ny < 0 || nx < 0 || ny >= N || nx >= N) continue;
    if(S[ny][nx] == 'o') dfs(ny, nx);
  }
}

int main()
{
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> S[i];
  }

  int ret = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      if(S[i][j] == 'o') dfs(i, j), ++ret;
    }
  }

  cout << ret / 3 << endl;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b;
    cin >>k>>a>>b;
    bool t=false;
    for(int i=a;i<b+1;i++){
        if(i%k==0){
            t=true;
        }
    }
    if(t==true){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, ans = 0;
	cin >> n;
	int ar[n+1];
	for(int i = 1; i <= n;i++){
		cin >> ar[i];
		if((i & 1) && (ar[i] & 1)) ans++;
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 3608
nums = list(map(int, list(input())))
size = len(nums)-1
for b in range(2**size):
    total = nums[0]
    outputs = [str(nums[0])]
    for i in range(size):
        if ( b & (1 << i) ):
            total = total + nums[1+i]
            outputs.append("+"+str(nums[1+i]))
        else:
            total = total - nums[1+i]
            outputs.append("-"+str(nums[1+i]))
    if(total == 7):
        outputs.append("=7")
        print(''.join(outputs))
        break

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long llong;
static const double pi = 3.141592653589793;

// 
void CalcKochPoint(vector<pair<long double, long double>> point, int depth) {
    vector<pair<long double, long double>> nextpoint(100);
    pair<long double, long double> s, t, u;

    if (depth == 0) return;
    int dep1 = depth / 3;
    int dep2 = depth / 3;
    int dep3 = depth / 3;
    int dep4 = depth / 3;

    s.first = (2 * point[0].first + point[1].first) / 3;
    s.second = (2 * point[0].second + point[1].second) / 3;

    t.first = (point[0].first + 2 * point[1].first) / 3;
    t.second = (point[0].second + 2 * point[1].second) / 3;

    u.first = (t.first - s.first) * cos(pi/3) - (t.second - s.second) * sin(pi/3) + s.first;
    u.second = (t.first - s.first) * sin(pi / 3) + (t.second - s.second) * cos(pi / 3) + s.second;

    // // 線分(P1,s)について求める
    nextpoint[0].first = point[0].first;
    nextpoint[0].second = point[0].second;
    nextpoint[1].first = s.first;
    nextpoint[1].second = s.second;
    CalcKochPoint(nextpoint, depth-1);

    std::cout << s.first << " " << s.second  <<"\n";

    // 線分(s,u)について求める
    nextpoint[0].first = s.first;
    nextpoint[0].second = s.second;
    nextpoint[1].first = u.first;
    nextpoint[1].second = u.second;
    CalcKochPoint(nextpoint, depth-1);

    std::cout << u.first <<" " << u.second <<"\n";

    // 線分(u,t)について求める
    nextpoint[0].first = u.first;
    nextpoint[0].second = u.second;
    nextpoint[1].first = t.first;
    nextpoint[1].second = t.second;
    CalcKochPoint(nextpoint, depth-1);

    std::cout << t.first <<" " << t.second << "\n";

    // 線分(t,p2)について求める
    nextpoint[0].first = t.first;
    nextpoint[0].second = t.second;
    nextpoint[1].first = point[1].first;
    nextpoint[1].second = point[1].second;
    CalcKochPoint(nextpoint, depth-1);

    // std::cout << nextpoint[1].first << setprecision(15) << " " << nextpoint[1].second << setprecision(15) << "\n";
}

int main() {
  vector<pair<long double, long double>> point(100);
  // 始点座標
  point[0].first = 0;
  point[0].second = 0;

  // 終点座標
  point[1].first = 100;
  point[1].second = 0;

  int n, k;
  cin >> n;
  k = pow(4, n) -1;
  //std::cout << k << "\n";
  std::cout << point[0].first << " " << point[0].second << "\n";
  CalcKochPoint(point, n);
  std::cout << point[1].first << " " << point[1].second << "\n";
}


Measured memory_bytes: 3312
#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;
    vector<int> A(N);
    rep(i,N) cin >> A.at(i);
    map<int, int> mp;
    long ans;
    long sum = 0;

    rep(i,N) ++mp[A.at(i)];
    for (auto iter = mp.begin(); iter != mp.end(); ++iter) {
        long n = iter->second;
        if (n >= 2) {
            sum += (n*n - n) / 2;
        }
    }
    rep(i,N) {

        if (mp[A.at(i)] >= 2) {
            ans = sum - (mp[A.at(i)] - 1);
        } else {
            ans = sum;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 9868
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define maxn (1<<18)+1
#define mod 1000000007

int H,n,p[maxn];
int vis[maxn],id=0,sum[maxn];
int ans=0;
void add(int &x,int y){x=(x+y>=mod?x+y-mod:x+y);}
void go2(int x,int prod,bool left){
	if(x==1)return;
	prod=1ll*prod*x%mod;
	if(left){
		if(vis[x]<id)vis[x]=id,sum[x]=0;
		add(sum[x],prod);
	}
	else{
		if(vis[x^1]<id)vis[x^1]=id,sum[x^1]=0;
		add(ans,1ll*(x/2)*prod%mod*sum[x^1]%mod);
	}
	go2(x/2,prod,left);
}
void go(int x,int prod,bool left){
	prod=1ll*prod*x%mod;
	if(x>=n){go2(n+p[x-n+1]-1,prod,left);return;};
	go(x*2,prod,left);
	go(x*2+1,prod,left);
}

int main()
{
	scanf("%d",&H);n=1<<(H-1);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<n;i++){
		id++;
		go(i*2,i,true);
		go(i*2+1,1,false);
	}
	printf("%d",ans);
}

Measured memory_bytes: 4260
#include<iostream>
main(){long long n,x,i,l[51],p[51],A=0,th;std::cin>>n>>x;for(i=-1;++i<51;)l[i]=(p[i]=(2ll<<i)-1)*2-1;while(n){th=l[n]/2;if(++x>l[n])A+=p[n];else if(--x<2);else if(x<th){n--;x--;continue;}else if(x==th)A+=p[n-1];else{A+=p[--n]+1;x-=th+1;continue;}break;}std::cout<<A+(!n&&x);}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long 
using namespace std;
int main()
{
	int n;
	cin>>n;
	ll res=1LL;
	for(int i=1;i<=n;i++)
	{
		res=(res*i)%mod;
	}
	cout<<res;
	
}

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

#define ull unsigned long long int
#define ll long long int
#define vll vector<ll>
#define vi vector<int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define itr vll::iterator
#define all(c) c.begin(),c.end()
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define inf 1000000000000000001

#define rep(i, n)      for(ll i = 0; i <  n; ++i)
#define repA(i, a, n)  for(ll i = a; i <= n; ++i)
#define repD(i, a, n)  for(ll i = a; i >= n; --i)

using namespace std;

bool func(const pll &a, const pll &b){
    return a.s < b.s;
}

ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}

void solve(){
    ll n;
    cin >> n;
    repA(i, -2000, 2000){
        repA(j, -2000, 2000){
            if(i*i*i*i*i-j*j*j*j*j == n){
                cout << i << ' ' << j;
                return;
            }
        }
    }
}

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

    int t, tmp = 0;
    // cin >> t;
    t = 1;
    while(t--){
        // cout << "Case #" << ++tmp << ": ";
        solve();
        if(t) cout << "\n";
    }
    cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    int a,b;
    dsu A(n);
    rep(i,m) cin>>a>>b,A.merge(a-1,b-1);
    cout<<A.groups().size()-1;
}

Measured memory_bytes: 9040
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	static BufferedReader br;
	
	public static void main(String[] args) throws IOException{
		br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		if(isApprove()) {
			System.out.println("APPROVED");
		}else {
			System.out.println("DENIED");
		}
	
		br.close();

	}
	
	private static boolean isApprove() throws IOException {
		boolean flg=true;
		String line[] = br.readLine().split(" ");
		
		for(int i=0;i<line.length;i++) {
			int num = Integer.parseInt(line[i]);
			if(num%2==0 && (num%3!=0 && num%5!=0)) {
				flg=false;
			}
		}
		return flg;
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v, n) sort(v, v+n)
#define print(x) cout << x << endl;

using namespace std;

const int MAX = 2000001;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H, W, A, B;
    cin >> H >> W >> A >> B;
  	H-=1;
  	W-=1;
    A-=1;
    B-=1;
  	COMinit();
  	
  	int Total;
  	Total = COM(H+W, H);
  	int tmp = 0;
  	FOR(i, 0, A+1){
    	tmp += COM(H+B-i, B)*COM(W-B-1+i, i)% MOD;
        tmp %= MOD;
    }
      
  	print((MOD + Total - tmp)% MOD)
    return 0;
}

Measured memory_bytes: 47104
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <tuple>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007

const int INF = 1e9;

int main(){
	int N,T;
	cin >> N >> T;
	int ans = INF;
	for(int i = 0; i < N; i++){
		int c, t; cin >> c >> t;
		if(t <= T && c < ans){
			ans = c;
		}
	}
	if(ans == INF){
		cout << "TLE" << endl;
	}else{
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define pi acos(-1.0)

int main()
{
    ll i, j, n, m, k = 65;
    string s;
    cin >> n >> s;
    vector < pair < char, int > > vp(26);
    for(i = 0; i < 26; i++){
        vp[i].first = char(k++);
        vp[i].second = i;
    }
//
//    for(auto it : vp){
//        cout << it.first << " " << it.second << endl;
//        cout << vp[(it.second + n) % 26].first << endl;
//    }

    for(i = 0; i < s.size(); i++){
        cout << vp[(vp[s[i] - 65].second + n) % 26].first;
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200005;
int a[N],b[N],h[N],to[N];
int n,w;
ll K;
void solve(int p,int s)
{
	memset(b,0,sizeof(b));
	for(int i = 1;i <= s;i ++)
	{
		if(!b[a[p]])
			h[++ w] = a[p],b[a[p]] = 1;
		else
		{
			while(h[w] != a[p])
				b[h[w]] = 0,w --;
			b[h[w]] = 0;w --;
		}
		p = p%n+1;
	}
	for(int i = 1;i <= w;i ++)
		printf("%d ",h[i]);
}
void solve2(int p,ll s)
{
	while(to[p]-p+1 <= s)
	{
		s -= to[p]-p+1;
		p = to[p]%n+1;
	}
	solve(p,s);
}
int main()
{
	scanf("%d%lld",&n,&K);
	for(int i = 1;i <= n;i ++)
		scanf("%d",&a[i]);
	for(int i = n;i >= 1;i --)
		b[a[i]] = i+n;
	for(int i = n;i >= 1;i --)
		to[i] = b[a[i]],b[a[i]] = i;
	memset(b,0,sizeof(b));
	int p = 1;ll s = 0,sc = 0;
	while(!b[p])
	{
		b[p] = 1;
		s += to[p]-p+1;
		p = to[p]%n+1;
	}
	int q = p;
	while(true)
	{
		sc += to[q]-q+1;
		q = to[q]%n+1;
		if(q == p)
			break;
	}
	if(n*K <= s)
		solve(1,n*K);
	else
		solve2(p,(n*K-s)%sc);
    return 0;
}

Measured memory_bytes: 4608
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

void solve() {
	string s; cin >> s;
	int n = s.length();
	int loc;
	rep(i, n) {
		if (s[i] == '*')loc = i;
	}
	int ans = 0;
	rep(i, loc) {
		Rep(j, loc + 1, n) {
			if (s[i] != '(' || s[j] != ')')continue;
			int c = 0;
			for (int k = i + 1; k <= j-1; k++) {
				if (s[k] == '(')c++;
				else if (s[k] == ')')c--;
				if (c < 0)break;
			}
			if (c == 0)ans++;
		}
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 3248
//N*X-2*(X and Abitsum)が最大になればよい
//上の式の各bitの数値を格納するint変数、bitar[64]
//それをYとするとsum(A,A+N)+Yがfの最大値になる
#include <bits/stdc++.h>
using namespace std;

void splitbit(vector<long long> &bitar,long long v){
  long long a=1;
  for(int i=0;i<64;i++){
    bitar[i]+=((v&a)!=0);
    a*=2;
  }
}

int main(){
  int N;
  long long K;
  cin>>N>>K;
  vector<long long> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  //例外処理
  if (K==0){
    long long sum = accumulate(a.begin(),a.end(), 0LL);
    cout<<sum<<endl;
    return 0;
  }
  
  
  //各bitの情報を格納するint変数
  vector<long long> bitar(64,0);
  //すべてのaをbitに分解
  for(int i=0;i<N;i++){
    splitbit(bitar,a[i]);
  }
  
  //N-2*bitarを計算
  for(int i=0;i<64;i++){
    bitar[i]=(N-2*bitar[i])*(1LL<<i);
  }
  
  //Y=X and bitarとしたときYが一番大きくなるようなYを求めたい
  int keta=0;//2新数でxが最大何桁あるか
  long long kdmy=K;
  while(kdmy>0){
    kdmy/=2;
    keta++;
  }
  
  /*
  /////////////////////////////
  long long maxs=0;
  for(int x=0;x<K+1;x++){
    long long s=0;
    for(int i=0;i<N;i++){
      s+=a[i]^x;
    }
    maxs=max(s,maxs);
  }
  cout<<maxs<<endl;
  return 0;
  /////////////////////////////
  */
  /*
  //////////////////////////
  //Y=X and bitarとしたときYが一番大きくなるようなYの場合
  long long maxs=0;
  int maxx=0;
  for(int x=0;x<K+1;x++){
    long long b=1;
    long long s=0;
    for(int i=0;i<64;i++){
      if ((x&b)!=0)
        s+=bitar[i];
      b*=2;
    }
    if (maxs<s){
      maxs=s;maxx=x;}
  }
  cout<<maxs+accumulate(a.begin(),a.end(), 0LL)<<endl;
  return 0;
  //////////////////////////
  */
  
  
  //あとでk<max(a)のときのことを考慮・・・しなくてよい
  //あとで使用するための変数
  vector<long long> sar(keta-1,0);//各桁で最大どうなるか
  long long s=0;
  for(int i=0;i<keta-1;i++){
    if (bitar[i]>0)
      s+=bitar[i];
    sar[i]=s;
  }
  
  if (bitar[keta-1]<=0){//このとき答えが一意に決まる
    long long sum = accumulate(a.begin(),a.end(), 0LL);
    cout<<(sum+s)<<endl;
    return 0;
  }
  
  
  //X=2^(keta-1)～KまででY=X and bitarとしたときYが一番大きくなるようなYを求めたい
  vector<long long> y(keta-1,0);
  s=bitar[keta-1];//ここはプラスになっている
  for(int i=keta-2;i>=0;i--){//上から、各bitで0or1を選択したときに、最大Yがどうなるか
    //そもそも1を選択できるか
    if ((K&(1LL<<i))!=0){
      if (i!=0){
	      y[i]=s+sar[i-1];//1を選択できるのに0を選択したとき,下の桁はすべて1を選ぶことができる
      }else{
          y[i]=s;
      }
      s+=bitar[i];//1を選択した場合
    }
  }
  //sには、最後まで可能な限り1を選択した場合、つまりX=Kの場合の最大Yとなっている
  
  //最大値をもとめる
  for(int i=0;i<keta-1;i++){
    if (s<y[i])
      s=y[i];
  }
  
  
  long long sum = accumulate(a.begin(),a.end(), 0LL);
  cout<<(sum+s)<<endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

int main()
{
    int a,b;
    cin >> a >> b;
    int ans=max(0,a-2*b);
    cout << ans << endl;
}

Measured memory_bytes: 3592
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

d, t, s = inintm()

if s*t >= d:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	unsigned int A, B, K;
	int condition, i;

	cin >> A >> B >> K;
	condition = A+K > B ? B+1 : A+K;
	for(i = A; i < condition ; ++i) {
		cout << i << endl;
	}
	condition = B-K+1 > i ? B-K+1 : i;
	for(i = condition; i<=B; i++) {
		cout << i << endl;
	}

	return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

n = int(input())
a = [0] + list(accumulate(map(int, input().split())))

dp = [[0] * (n + 1) for i in range(n + 1)]

for i in range(n)[::-1]:
    for j in range(i + 1, n + 1):
        if j - i == 1:
            continue
        dp[i][j] = min([dp[i][k] + dp[k][j] for k in range(i + 1, j)])
        dp[i][j] += a[j] - a[i]

print(dp[0][n])


Measured memory_bytes: 43356
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,l,i,j;
	char s[100][101],wk[101];
	scanf("%d %d",&n,&l);
	for(i=0;i<n;i++)	scanf("%s",s[i]);
//	for(i=0;i<n;i++)	sort(s[i],s[i]+l);
	for(i=0;i<n-1;i++)	{
		for(j=i+1;j<n;j++)	{
			if(strcmp(s[i],s[j])>0)	{
				strcpy(wk,s[i]);
				strcpy(s[i],s[j]);
				strcpy(s[j],wk);
			}
		}
	}
	for(i=0;i<n;i++)	printf("%s",s[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<998244353>;


//二項係数ライブラリ
const int MAX = 1000000;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//前処理COMinit()忘れずに


void solve() {
    int N, M, K; cin >> N >> M >> K;

    COMinit();

    mint ans = 0;

    for (int i = 0; i <= K; i++) {
        ans += modpow(mint(M-1), N - i - 1) * M * COM(N-1, N-i-1);
    }

    cout << ans << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 27068
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  int a,b,c,d;cin >>a>>b>>c>>d;
  cout << max(0,a-b);
}



Measured memory_bytes: 256
N = int(input())
S = input()
LS = list(S)
L = len(S)

alpha2num = lambda x: ord(x) - ord('A') + 1
num2alpha = lambda x: chr(x+64)

for i in range(L):
    num = alpha2num(LS[i]) + N
    if num <= 26:
        LS[i] = num2alpha(num)
    else:
        LS[i] = num2alpha(num-26)

print(''.join(LS))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;

	vector<int> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}

	vector<int> dp(k + 1);
	for (int i = 0; i <= k; i++)
	{
		for (int j : arr)
		{	
			if (i >= j && !dp[i - j])
			{
				dp[i] = true;
			}
		}
	}

	cout << (dp[k] ? "First" : "Second") << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;
const int MAX_N = 1e5+100;
int A[MAX_N], B[MAX_N];

int main(){
  //  freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    int N;
    cin >> N;
    for(int i = 1; i <= N; ++i) {
        cin >> A[i];
        A[i] *= 2;
    }
    LL sum = A[N-1];
    int x = 1;
    for(int i = N-2; i >= 1; --i){
        x *= -1;
        sum += x*A[i];
    }
    sum += A[N];
    B[N] = sum/2;
    B[1] = A[N]-B[N];
    for(int i = 1; i < N; ++i){
        B[i+1] = A[i] - B[i];
    }
    for(int i = 1; i <= N; ++i){
        cout << B[i] << " ";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 2176
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W;
  cin>>H>>W;
  vector<string> A(H);
  for(int i=0;i<H;++i) cin>>A[i];
  queue<tuple<int, int, int> > que;
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      if(A[i][j]=='#') {
        que.push(make_tuple(i, j, 0));
      }
    }
  }
  tuple<int, int, int> state;
  int x, y, num;
  int ans = 0;
  while(!que.empty()) {
    state = que.front();que.pop();
    x = get<0>(state);
    y = get<1>(state);
    num = get<2>(state);
    ans = max(ans, num);
    if(x>0 && A[x-1][y]=='.') {
      A[x-1][y] = '#';
      que.push(make_tuple(x-1, y, num+1));
    }
    if(x<H-1 && A[x+1][y]=='.') {
      A[x+1][y] = '#';
      que.push(make_tuple(x+1, y, num+1));
    }
    if(y>0 && A[x][y-1]=='.') {
      A[x][y-1] = '#';
      que.push(make_tuple(x, y-1, num+1));
    }
    if(y<W-1 && A[x][y+1]=='.') {
      A[x][y+1] = '#';
      que.push(make_tuple(x, y+1, num+1));
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 17120
N, M = map(int, input().split())

if N == 1 and M != 1:
    print(M - 2)
elif N != 1 and M == 1:
    print(N - 2)
elif N == 1 and M == 1:
    print(1)
else:
    print((N - 2) * (M - 2))

Measured memory_bytes: 38384
M = 0
i = 1
while i ** 5 - (i-1) ** 5 <= 10**9:
    i += 1
M = i

X = int(input())
for B in range(-M, M + 1):
    for A in range(B + 1, M + 1):
        if A**5 - B**5 == X:
            print(A, B)
            break
    else:
        continue
    break

Measured memory_bytes: 9124
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;
#define inf 0x3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mp make_pair
#define pb push_back
#define sz(v) (int)v.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
//const int N=1e6+7;

int main(){
    fast;
    int t=1;
    //cin>>t;
    for1(ks,t){
        int a=0;
        string s="CODEFESTIVAL2016",t;
        cin>>t;
        forn(i,16){
            if(s[i]!=t[i]) a++;
        }
        cout<<a<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;

int main()
{
  char s[10];
  scanf("%s",s);
  REP(i,3){
    if(s[i]==s[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}

Measured memory_bytes: 256