akhauriyash/Code-Regression huggingface dataset:
// Problem : D - Banned K
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);
#define endl "\n"
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;

const int N = (int)2e5+5;
int a[N], f[N];

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)	
		cin >> a[i];
	for(int i = 1; i <= n; i++) 
		f[a[i]]++;
	int tot = 0;
	for(int i = 1; i <= n; i++)
		tot += (f[i]*(f[i]-1)/2);
	for(int i = 1; i <= n; i++)
	{
		int temp = f[a[i]]-1;
		cout << tot - temp << endl;
	}
	return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define Iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

int main()
{
	int n;
	ll d;
	scanf("%d%lld", &n, &d);

	d *= d;

	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		ll a, b;
		scanf("%lld%lld", &a, &b);

		if (a * a + b * b <= d)
			ans++;
	}

	printf("%d", ans);
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll w,d,n;
	cin >> w >> d >> n;
	ll limith[w][d],limitl[w][d];
	FOR(i,0,w)FOR(j,0,d)limith[i][j]=MOD;
	FOR(i,0,w)FOR(j,0,d)limitl[i][j]=-MOD;
	FOR(i,0,n){
		ll x,y,z;
		cin >> x >> y >> z;
		x--;y--;
		if(limitl[x][y]>z || limith[x][y]<z){
			cout << "No" << endl;
			return 0;
		}
		limith[x][y] = z;
		limitl[x][y] = z;
		FOR(j,0,w)FOR(k,0,d){
			ll d = abs(x-j)+abs(y-k);
			if(limith[j][k]<z-d){
				cout << "No" << endl;
				return 0;
			}
			if(limitl[j][k]>z+d){
				cout << "No" << endl;
				return 0;
			}
			if(limith[j][k]>z+d){
				limith[j][k]=z+d;
			}
			if(limitl[j][k]<z-d){
				limitl[j][k]=z-d;
			}
		}
	}
	ll ans = 0;
	FOR(i,0,w){
		FOR(j,0,d){
			ans += limitl[i][j];
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3140
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int H = scan.nextInt();
        int W = scan.nextInt();
        while (H != 0 || W != 0) {
            for ( int a = 1; a <= H; a++) {
                for ( int b = 1; b <= W; b++) {
                    if(a == 1 || a == H || b == 1 || b == W){
                      System.out.print("#");
                    } else{
                      System.out.print(".");
                }        
                }
                      System.out.println("");
                }     System.out.println("");
                      H = scan.nextInt();
                      W = scan.nextInt();
        }
        
}
}



Measured memory_bytes: 32876
#include <iostream>

using namespace std;
typedef long long ll;
const int N=2e5+10;
const int M=1e6+10;
const int mod=998244353;
int primes[M/10],tot;
bool check[M];
int a[M];
int mu[M];
ll cnt[M];
int f[M];
ll inv[M];
void init(int n)
{
    mu[1]=1;
    inv[1]=1;
    for(int i=2;i<=n;i++)
    {
        inv[i]=1ll*(mod-(mod/i))*inv[mod%i]%mod;
        if(!check[i]){
            primes[++tot]=i;
            mu[i]=-1;
        }
        for(int j=1;primes[j]*i<=n;j++)
        {
            check[i*primes[j]]=true;
            if(i%primes[j]==0){
                mu[i*primes[j]]=0;
                break;
            }mu[i*primes[j]]=-mu[i];
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j+=i)
        {
            f[i]=(f[i]+cnt[j])%mod;
        }
    }
}
int main()
{
    int n;
    cin>>n;
    int maxv=0;
    int sum=0;
    for(int i=1;i<=n;i++)cin>>a[i],maxv=max(maxv,a[i]),cnt[a[i]]=(cnt[a[i]]+a[i])%mod,sum=(sum+a[i])%mod;
    init(maxv);
    ll ans=0;
    for(int i=1;i<=maxv;i++)
    {
        for(int j=1;j<=maxv/i;j++)
        {
            ans=(ans+1ll*f[i*j]%mod*f[i*j]%mod*mu[j]*inv[i])%mod;
        }
    }
    ans=(ans-sum+mod)%mod;
    ans=(ans*inv[2])%mod;
    cout<<ans<<endl;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int>p;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }
    sort(p.rbegin(),p.rend());
    // for(int i=0;i<n;i++){
    //     cout << p[i] << ' ';
    // }
    // cout << endl;
    int sum = accumulate(p.begin(),p.end(),0);

    sum -= p[0]/2;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int a, b;
	cin >> a >> b;

	int diff = b - a;
	int value = 0;

	for (int i = 1; i < diff; i++)
	{
		value += i;
	}

	cout << value - a;

	return 0;
}

Measured memory_bytes: 3600
import queue

N = int(input())

u, v, w = [0 for _ in range(N-1)], [0 for _ in range(N-1)], [0 for _ in range(N-1)]

adli = [[] for _ in range(N)]

for i in range(N-1):
    u[i], v[i], w[i] = map(int, input().split())
    adli[u[i]-1].append([v[i]-1, w[i]%2])
    adli[v[i]-1].append([u[i]-1, w[i]%2])

col = [-1 for _ in range(N)]
col[0] = 0

q = queue.Queue()
q.put((0, 0))
c = 0

while(not q.empty()):
    a = q.get()
    col[a[0]] = a[1]

    for e in adli[a[0]]:
        if col[e[0]] == -1:
            q.put((e[0], (a[1]+e[1])%2))

for ans in col:
    print(ans)


Measured memory_bytes: 55888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,s,e) for(int i=s;i<e;i++)

int main(){
    int a,b;
    cin>>a>>b;
    if(a+b==15)
        cout<<"+";
    else if(a*b==15)
        cout<<"*";
    else
        cout<<"x";
return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll n, m;
  cin >> n >> m;
  llvec x(n), y(m);
  rep(i, n)cin >> x[i];
  rep(i, m)cin >> y[i];
  ll ans = 0;
  ll xsum=0;
  rep(i, n-1){
    ll t = x[i+1] - x[i];
    xsum = mod(xsum + t*(i+1)*(n-1-i), MOD);
  }
  cerr << xsum << endl;
  rep(i, m-1){
    ll t = y[i+1] - y[i];
    ans = mod(ans+mod(t*(i+1)*(m-1-i),MOD)*xsum, MOD);
  }
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 4832
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
        n:usize,m:usize,s:usize,
    uvab : [(Usize1,Usize1,usize,usize);m],// city,city,fee, transit time
    cd:[(usize,usize);n],// money, time
    }
    let mut G = vec![Vec::new(); n + 1];
    for &(u, v, a, b) in uvab.iter() {
        G[u].push((v, a, b));
        G[v].push((u, a, b));
    }
    let mut s = s;
    /**
     * 銀貨は最大でも2500枚あればよい -> 制約ゆるくなる
     * */
    let MAX = 2500usize;
    if s >= MAX {
        s = MAX;
    }
    // [頂点, 金]への最大値
    let mut dp = vec![vec![INF as usize; MAX + 1]; n];
    let mut qq = BTreeSet::new();
    dp[0][s] = 0;
    // ダイクストラの拡張
    // que.push((0 as i64, 0 as i64, -(s as i64)));
    qq.insert((0, 0, s));
    while qq.len() > 0 {
        let tp = *qq.iter().next().unwrap();
        qq.remove(&tp);
        // dbg!(que.len());
        let time = (tp.0) as usize;
        let v = (tp.1) as usize;
        let ss = (tp.2) as usize;
        // 最大より時間がかかるなら無視
        if time > dp[v][ss] {
            continue;
        }
        // 両替する
        if ss + cd[v].0 <= MAX {
            let ns = ss + cd[v].0;
            let ntime = time + cd[v].1;
            if dp[v][ns] > ntime {
                dp[v][ns] = ntime;
                qq.insert((ntime, v, ns));
            }
        }
        for &e in G[v].iter() {
            if ss < e.1 {
                continue;
            }
            let nv = e.0;
            let ns = ss - e.1;
            let ntime = time + e.2;
            if dp[nv][ns] > ntime {
                dp[nv][ns] = ntime;
                qq.insert((ntime, nv, ns));
            }
        }
    }
    for v in 1..n {
        let mut res = INF as usize;
        for s in 0..=MAX {
            res = min(res, dp[v as usize][s as usize]);
        }
        println!("{}", res);
    }
}

const INF: usize = 1 << 55;


Measured memory_bytes: 6160
# 入力
N, A, B, C = map(int, input().split())

MOD = 10**9 + 7


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )


f = [0 for _ in range(2 * N)]
f[0] = ModInt(1)
for i in range(1, 2 * N):
    f[i] = i * f[i - 1]

# 引き分けなしの分母
D = ModInt(100 - C)
# 1回のゲームにつき、高橋君が勝つ確率
p = A / D
# 1回のゲームにつき、青木君が勝つ確率
q = B / D

# 高橋君がN回、青木君がi回勝つケースの重み付き期待値の和、および
# 高橋君がi回、青木君がN回勝つケースの重み付き期待値の和
# を求めそれらの和を解とする
ans = (100 / D) * sum(
    (N + i) * (f[N + i - 1] / (f[i] * f[N - 1])) * (p**N * q**i + p**i * q**N)
    for i in range(N)
)

# 出力
print(ans)


Measured memory_bytes: 67276
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**9
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    h,w = LI()
    n = I()
    a = LI()

    r = [0] * (h*w)
    t = 0
    for i in range(1,n+1):
        c = a[i-1]
        for j in range(c):
            r[t+j] = i
        t += c
    rr = []
    for i in range(h):
        t = r[i*w:i*w+w]
        if i % 2 == 1:
            t.reverse()
        rr.append(t)

    return '\n'.join([' '.join(map(str, r)) for r in rr])



print(main())



Measured memory_bytes: 6092
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const long long inf=1e9;
int32_t main()
{
	int n;
  cin>>n;
  int arr[n+1];
  for(int i=1;i<=n;i++)cin>>arr[i];
  
  int dp[n+1];
  dp[1]=0;
  dp[2]=abs(arr[2]-arr[1]);
  for(int i=3;i<=n;i++){
    int option1=dp[i-1] + abs(arr[i]-arr[i-1]);
    int option2=dp[i-2] + abs(arr[i]-arr[i-2]);
    dp[i]=min(option1,option2);
  }
  cout<<dp[n];
  return 0;
}
  
  
  

Measured memory_bytes: 1792
//author-micheal corleone
//the godfather
#include <bits/stdc++.h>
#include <set> 
#include<algorithm>

#include <set> 
#include<algorithm>
#define ll long long int

const int MOD = 1e9+7;
#define f(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
 
using namespace std;
 
 bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[1] < v2[1]; 
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}
 

ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
  //  ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
const int maxn=2e5+100;
vector<int>v[maxn];
ll vv[maxn];
ll vis[maxn]={0};

void dfs(ll x)
{
	vv[x]=1;
	for(int i=0;i<v[x].size();i++)
	{
		if(vv[v[x][i]]==0) dfs(vv[v[x][i]]);
	}
}


int main()
{
	ios_base::sync_with_stdio(0);
   cin.tie(0);
    cout.tie(0);
    
    
     ll t;
     //cin>>t;
     t=1;
   while(t--)
    {
        ll n,i1,i2,k,m,j,j1,a1,f,i31,i3,j2,i5,i4,i6,i7,i;
        i4=INT_MIN,i1=0;
        f=0;
        ll res,res1,ans;
        ans=1,res=0;
        res1=0;
        ll s1,s2,s3;
        s2=0;    
        s1=0;
        ll q;
        i31=1;
        s3=-1;
        ll x;
        ll cnt=0;
         cin>>n>>m;
         ll a[m];
         f(i,0,m)
         {
         	cin>>a[i];
         	s1=s1+a[i];
		 }
		 if(n-s1<0) cout<<-1<<endl;
		 else cout<<n-s1<<endl;
         
	
         
	
	}
}
		

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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  
  if (U == S) {
    cout << A -1 << ' ' << B << endl;
  }
  else {
    cout << A <<' '<< B - 1 << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N-1):
    u,v,w = map(int, input().split())
    edge[u-1].append((v-1, w))
    edge[v-1].append((u-1, w))

dist = [-1] * N
dist[0] = 0
stack = [0]
while stack:
    u = stack.pop()
    d = dist[u]

    for v,w in edge[u]:
        if dist[v] > 0:
            continue
        dist[v] = d + w
        stack.append(v)

for d in dist:
    if d % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 42796
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() 
#define higher(v,x) high2way(v,x)-v.begin()-1 
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
#define erase(s) s.erase(s.end()-1) //文字列sの末尾削除

ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
string RLE(string s){
  ll n=s.size();
  char now='.';
  ll count=1;
  string press;
  loop(i,n){
    if(s[i]!=now){
      if(i){
        press+=now;
        press+=to_string(count);
      }
      now=s[i];
      count=1;
      continue;
    }
    else count++;
  }
  press+=now;
  press+=to_string(count);
  return press;
}
// index が条件を満たすかどうか
bool isOK(vec a,ll index,ll key) {
    if(a[index]>=key)return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search(vec a,ll key) {
    ll ng=-1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll ok=(ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        if(isOK(a,mid,key))ok=mid;
        else ng=mid;
    }
    return ok;
}

int main() {
  cout << fixed << setprecision(30);
  ll n,m;
  cin>>n>>m;
  vector<string> a(n);
  vector<string> b(m);
  loop(i,n)cin>>a[i];
  loop(i,m)cin>>b[i];
  bool check=true;
  bool ans=false;
  loop(i,n-m+1){
    loop(j,n-m+1){
      check=true;
      loop(k,m){
        loop(l,m){
          if(a[i+k][j+l]!=b[k][l])check=false;
        }
      }
      if(check)ans=true;
    }
  }
  if(ans)putout("Yes");
  else putout("No");
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<long,long>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}
int main(){
    string s;
    cin >> s;
    cout << s.substr(0,3) << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <sstream>
using namespace std;
int main()
{
	int n, k;
	string s;
	cin >> s;
	k = (int)s.size();
	n = 0;
	for (int i = 0; i < k; i++) {
		if (s[i] == 'o') {
			n++;
		}
	}
	n += 15 - k;
	s = (n >= 8) ? "YES" : "NO";
	cout << s << endl;
	return(0);
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int H,W;
	scanf("%d %d",&H,&W);
	char s[51][51];
	int i,j;
	for(i=0;i<H;i++){scanf("%s",s[i]);}
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			if(s[i][j]=='.'){
				int count=0;
				for(int k=-1;k<2;k++){
					for(int l=-1;l<2;l++){
						if(i+k>=0&&j+l>=0&&s[i+k][j+l]=='#'){count++;}
					}
				}
				printf("%d",count);
			}
			else{printf("#");}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll n,m,st,ok;
vector<ll> v;
int main(void){
    cin>>n>>m;
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    while(1){
        //cout<<st<<endl;
        if(st==n){
            ok=1;
            break;
        }
        for(int i=min(m,n-st);i>=1;i--){
            //cout<<s[st+i]<<"i"<<endl;
            if(s[st+i]=='0'){
                st+=i;
                v.push_back(i);
                break;
            }
            else if(i==1)ok=-1;
        }
        if(ok==-1)break;
    }
    reverse(v.begin(),v.end());
    if(ok==1){
        for(auto x:v)cout<<x<<" ";
        cout<<endl;
    }
    else cout<<-1<<endl;
}


Measured memory_bytes: 1528
#include <iostream>

using namespace std;

void solve(int H,int W,int N) {
    int moji[H][W];
    int cnt[H+1][W+1];
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            cin >> moji[i][j]; // 0->south / 1->east
        }
    }

    // count visits for N-1 walk
    cnt[0][0]=N-1;
    for(int j=0; j<W-1; ++j) {
        cnt[0][j+1]=(cnt[0][j]+moji[0][j])/2;
    }
    for(int i=0; i<H-1; ++i) {
        cnt[i+1][0]=(cnt[i][0]+1-moji[i][0])/2;
    }
    for(int i=0; i<H-1; ++i) {
        for(int j=0; j<W-1; ++j) {
            cnt[i+1][j+1]=(cnt[i+1][j]+moji[i+1][j])/2+(cnt[i][j+1]+1-moji[i][j+1])/2;
        }
    }
    // calculate status after N-1 walk
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            moji[i][j]=(moji[i][j]+cnt[i][j])%2;
        }
    }
    // Nth walk
    int h=0, w=0;
    while(h<H && w<W) {
        if(moji[h][w]==0) ++h;
        else ++w;
    }
    cout << h+1 << " " << w+1 << endl;

    return;
}

int main() {
    int H,W,N;
    while(true) {
        cin >> H >> W >> N;
        if(H==0 && W==0 && N==0) break;
        solve(H,W,N);
    }
    return 0;
}


Measured memory_bytes: 10908
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> left(q), right(q);
  for(int i = 0; i < q; i++){
    cin >> left[i] >> right[i];
  }
  vector<ll> acl(n, 0), acr(n, 0);
  for(int i = 0; i < n - 1; i++){
    acr[i + 1] = acr[i];
    if(s[i] == 'A' && s[i + 1] == 'C') {
      acr[i + 1]++;
    }
  }
  for(int i = 0; i < n - 1; i++){
    if(s[i] == 'A' && s[i + 1] == 'C') {
      acl[i]++;
    }
    acl[i + 1] = acl[i];
  }
  /*
  for(int i = 0; i < n; i++){
    cout << acr[i] << " " ;
  }
  cout << "\n";
  for(int i=0; i<n; i++){
    cout << acl[i] << " " ;
  }
  */
  cout << "\n";
  for(int i = 0; i < q; i++) {
    cout << acr[right[i] - 1] - acr[left[i] - 1] << "\n";
    }
  return 0;
}

Measured memory_bytes: 3456
/** 
 *  Author : Parth Prajapati aka (PARTH_4399, hungry_chef)
 *  Institute : Pandit Deendayal Petroleum University
 **/
#include<bits/stdc++.h>

using namespace std; 

#define start_cooking int main()
#define food_is_ready return 0;
#define main_ingredient_added ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void cook()
{
    // start with your recipe
    int n;
    long long cnt = 0;
    bool f = 0;
    cin>>n;
    vector<int> a(n);
    map<int, int> mp;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        ++mp[a[i]];
    }
    for(int i=0;i<n;++i)
    {
        int j;
        f = 0;
        if(a[i] == 1)
        {
            if(mp[a[i]] == 1)
                ++cnt;
            continue;
        }
        for(j=1;j<=sqrt(a[i]);++j)
        {
            if(a[i]%j == 0)
            {
                if(mp[j] > 0)
                {
                    f = 1;
                    break;
                }
                if(mp[a[i]/j] > 0)
                {
                    if(j == 1 && mp[a[i]] > 1)
                    {
                        f = 1;
                        break;
                    }
                    if(j != 1)
                    {
                        f = 1;
                        break;
                    }
                }
            }
        }
        if(!f)  ++cnt;
        //cout<<j<<" "<<cnt<<"\n";
    }
    cout<<cnt;
}

start_cooking
{
    main_ingredient_added
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1; 
    //cin>>t;
    while(t--)
        cook();
    food_is_ready
}

Measured memory_bytes: 33032
import java.util.*;
import static java.lang.System.*;

//https://atcoder.jp/contests/abc054/tasks/abc054_c
public class Main {
    static int ans = 0;

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

        int N = sc.nextInt();
        int M = sc.nextInt();

        int[][] ab = new int[N][N];
        for (int m = 0; m < M; m++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            ab[a - 1][b - 1] = 1;
            ab[b - 1][a - 1] = 1;
        }

        solver(ab, N);
    }

    public static void solver(int[][] ab, int N) {
        int pos = 0;
        int[] passed = new int[N];

        solver_helper(ab, N, pos, passed);
        out.println(ans);
    }

    public static int solver_helper(int[][] ab, int N, int pos, int[] passed) {
        // 通った頂点として記録
        passed[pos] = 1;

        // 全ての頂点を通っているかの確認
        boolean all_passed = true;
        for (int n = 0; n < N; n++) {
            if (passed[n] == 0) {
                //out.println("not passed:"+n);
                all_passed = false;
                break;
            }
        }

        if (all_passed == true){
            //out.println("all passed");
            ans++;
        }

        // 次の頂点への移動
        //out.println("passed:"+Arrays.toString(passed));
        for (int n = 0; n < N; n++) {
            //out.println("  check n:"+n+", ans:"+ans);
            if (ab[pos][n] == 1 && passed[n] != 1) {
                //out.println("==> next(from->to):"+pos+"->"+n);
                int[] copiedPassed = new int[N];
                System.arraycopy(passed, 0, copiedPassed, 0, passed.length);
                //out.println("==> before ans:"+ans);
                solver_helper(ab, N, n, copiedPassed);
                //out.println("==> after ans:"+ans);
            }
        }

        // 全ての頂点を通っていない、かつ、次の頂点に行けなければ終わり
        return 0;
    }
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;

int main(int argc, char **argv) {
  int i;
  int N;
  string S;
  cin >> N >> S;

  int cnt = 0;
  int cur = -1;
  for (int i = 0; i < N; i++) {
    if (cur != S[i]) {
      cnt++;
      cur = S[i];
    }
  }
  cout << cnt << endl;

  return 0;
}


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

using namespace std;

#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)

struct Point{
  double x,y;

  Point(double x = 0,double y = 0) : x(x), y(y) {}

  Point operator + (const Point &p)const{
    return Point(x + p.x , y + p.y);
  }

  Point operator - (const Point &p)const{
    return Point(x - p.x , y - p.y);
  }

  Point operator * (const double &k)const{
    return Point(x * k , y * k);
  }

  Point operator / (const double &k)const{
    return Point(x / k , y / k);
  }

  bool operator < (const Point &p)const{
    if(x != p.x) return x < p.x;
    else return y < p.y;
  }

  double dot(const Point &p)const{
    return x*p.x + y*p.y;
  }

  double cross(const Point &p)const{
    return x*p.y - p.x*y;
  }

  double dist(const Point &p)const{
    return sqrt(pow(x-p.x,2) + pow(y-p.y,2));
  }

  double norm(){
    return x*x + y*y;
  }

  double Abs(){
    return sqrt(norm());
  }
};

typedef Point Vector;

struct Line{
  Vector s,t;
 
  Line(){}
  Line(Vector s, Vector t) : s(s), t(t) {}

  bool isOrthogonal(Line &l){
    Vector a = t - s;
    Vector b = l.t - l.s;
    if(equal(a.dot(b),0.0)){
      return true;
    }else{
      return false;
    }
  }

  bool isParallel(Line &l){
    Vector a = t - s;
    Vector b = l.t - l.s;
    if(equal(a.cross(b),0.0)){ 
      return true; 
    }else{
      return false;
    }
  }

  Point Projection(Point &p){
    Vector u = t - s;
    double v = u.dot(p - s) / u.norm();
    return s + u * v;
  }

  Point CrossPoint(Line &l){
    Vector v = l.t - l.s;
    double a = abs(v.cross(s-l.s));
    double b = abs(v.cross(t-l.s));
    double c = a / (a + b);
    return s + (t - s) * c;
  }

  Point Reflection(Point &p){
    return p + (Projection(p) - p) * 2.0;
  }
};

int main(){
  int Q;
  cin >> Q;
  while(Q--){
    Line s1,s2;
    cin >> s1.s.x >> s1.s.y >> s1.t.x >> s1.t.y;
    cin >> s2.s.x >> s2.s.y >> s2.t.x >> s2.t.y;
    if(s1.isOrthogonal(s2)){
      cout << 1 << endl;
    }else if(s1.isParallel(s2)){
      cout << 2 << endl;
    }else{
      cout << 0 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
#define MAX 500000

int A[MAX],H;
void maxHeapify(int);

int main()
{
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++)
    {
      scanf("%d",&A[i]);
    }
  for(i=H/2;i>=1;i--)
    {
      maxHeapify(i);
    }
  for(i=1;i<=H;i++)
    {
      printf(" %d",A[i]);
    }
  printf("\n");
  return 0;
}

void maxHeapify(int i)
{
  int l,r,largest,change=0;
  l = 2*i;
  r = 2*i+1;
  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if ((l <= H)&&(A[l] > A[i]))
    {
      largest = l;
    }
  else
    {
      largest = i;
    }
  if ((r <= H )&& (A[r] > A[largest]))
    {
      largest = r;
    }

  if (largest != i)// i の子の方が値が大きい場合
    {
      //A[i] と A[largest] を交換
      change=A[i];
      A[i]=A[largest];
      A[largest]=change;
      maxHeapify(largest); // 再帰的に呼び出し
    }
}

/*
#include <stdio.h>
#define MAX 2000000

int h,a[MAX+1];

void maxHeapify(int i)
{
  int l,r,largest;
  int oki;
 
  l = 2 * i ;
  r = 2 * i + 1;

  if(l<=h && a[l] >a[i])largest=l;
  else largest = i;
  if(r <=h && a[r] > a[largest]) largest = r;

  if(largest != i){
    oki = a[i];
    a[i] = a[largest];
    a[largest] = oki;
    maxHeapify(largest);
  }
}
int main()
{
  int i;
  scanf("%d",&h);

  for(i=1;i<=h;i++) scanf("%d",&a[i]);

  for(i=h/2;i>=1;i--) maxHeapify(i);

  for(i=1;i<=h;i++){
    printf(" %d",a[i]);
  }
  printf("\n");

  return 0;
}


void buildMaxHeap(A)
{
  for (i=H/2;i>=1;i--)
    {
      maxHeapify(A, i);
    }
}

 */



Measured memory_bytes: 3664
#include <algorithm>
#include <iostream>
#include<string>
#include <stdio.h>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	if (a<=b)
	{
		cout << a << endl;
	}
	else
	{
		cout << a - 1 << endl;
	}
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
B = [0]*(N+1)

if N == 0:
    if A[0] != 1:
        print(-1)
        exit()
    else:
        print(1)
        exit()
if A[0] != 0:
    print(-1)
    exit()
else:
    B[0] = 1

C = [0]*(N+1)
C[0] = 1
for i in range(1,N+1):
    C[i] = 2*(C[i-1] - A[i-1])
    if C[i] < A[i]:
        print(-1)
        exit()

#print(C)
for i in range(N, 0, -1):
    if i == N:
        B[i] = A[i]
    else:
        B[i] = min(A[i]+B[i+1], C[i])
print(sum(B))


Measured memory_bytes: 679860
import java.util.Scanner;
import java.math.*;

public class Main{
    public static void main(String[] args){
        Scanner sc =new Scanner(System.in);
        int x=sc.nextInt();
        int n=sc.nextInt();
        int count1=0;
        int count2=0;
        int plus=0;
        int minus=0;
        int flg=0;
        if(n==0){
            System.out.println(x);
        }else{
        int[] list = new int[n];
        for(int i=0; i<list.length; i++){
            list[i]=sc.nextInt();
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+plus){
                    plus++;
                }
            }
            count1++;
            if(count1>plus){
                break;
            }
        }
        while(true){
            for(int i=0; i<list.length; i++){
                if(list[i]==x+minus){
                    minus--;
                }
            }
            count2--;
            if(count2<minus){
                break;
            }
        }
        flg=plus+minus;
        if(flg>=0){
            System.out.println(x+minus);
        }else if(flg<0){
            System.out.println(x+plus);
        }
    }
}
}

Measured memory_bytes: 35780
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int a;
	cin>>a;
	vector<int>b(a);
	for(int c=0;c<a;c++)cin>>b[c];
	for(int d=a-1;d!=0;d--)cout<<b[d]<<" ";
	cout<<b[0]<<endl;
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	if(n>=k){
		cout<<k*x+(n-k)*y<<endl;
	}
	if(n<k){
		cout<<n*x<<endl;
	}
}

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

int main() {
  int n, t=0, c=1;
  cin >> n;
  vector<pair<int, int>> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i).second >> a.at(i).first;
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++) {
    t += a.at(i).second;
    if(t > a.at(i).first) c=0;
  }
  if(c) cout << "Yes";
  else cout << "No";
}

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

using namespace std;

int main() {
    int D; cin>>D;
    map<int, string> m;

    m[25] = "Christmas";
    m[24] = m[25] + " Eve";
    m[23] = m[24] + " Eve";
    m[22] = m[23] + " Eve";

    cout << m[D] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define rep(i, N) for(int i=0; i<N; i++)
using namespace std;
using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;
// " ", ' '
// std::string str;
// str = std::to_string(int i);

// プロトタイプ宣言
// int myfunc(int, vvec);

// グローバル変数
// int N, M;
// vvec data(N, vec(M));

// 関数：

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N; cin >> N;
	cout << N*N*N << endl; 
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());//昇順ソート
#define usort(a) sort(a.rbegin(),a.rend());//降順ソート

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int main(){
  int N,H,W; cin>>N>>H>>W;
  cout<<(N+1-H)*(N+1-W);
}




// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 305;
const int mo = 1e+9+7;

int f[N][N][N];
int n,m;
int ad[N][N][N],v[4];

int add(int x,int y){return x+y>=mo?x+y-mo:x+y;}

int main(){
	//freopen("data.in","r",stdin);
//	freopen("data.out","w",stdout);
	n=get();m=get();
	fo(t,1,m){
		int l=get(),r=get(),x=get();
		if (x==1){
			ad[r][0][l]++,ad[r][0][r+1]--;
			ad[r][l][0]++,ad[r][r+1][0]--;
		}
		if (x==2){
			ad[r][0][0]++,ad[r][0][l]--,ad[r][l][0]--;
			ad[r][r+1][0]++,ad[r][0][r+1]++;
			ad[r][l][l]+=2;
			ad[r][r+1][l]-=2,ad[r][l][r+1]-=2;
			ad[r][r+1][r+1]+=2;
		}
		if (x==3){
			ad[r][0][0]++;
			ad[r][l][l]--,ad[r][r+1][l]++,ad[r][l][r+1]++,ad[r][r+1][r+1]--;
		}
	}
	fo(i,1,n)
		fo(j,0,n)
			fo(k,0,n){
				//ad[i][j][k]=(ad[i][j][k]+ad[i][j-1][k]+ad[i][j][k-1]-ad[i][j-1][k-1]);
				if (j)ad[i][j][k]+=ad[i][j-1][k];
				if (k)ad[i][j][k]+=ad[i][j][k-1];
				if (j&&k)ad[i][j][k]-=ad[i][j-1][k-1];
			}
	f[0][0][0]=1;
	fo(i,0,n)
		fo(j,0,n)
			fo(k,0,n){
				v[1]=i,v[2]=j,v[3]=k;
				sort(v+1,v+4);
				if (ad[v[3]][v[2]][v[1]])f[i][j][k]=0;
				else{
					int w=max(i,max(j,k));
					f[w+1][j][k]=add(f[w+1][j][k],f[i][j][k]);
					f[i][w+1][k]=add(f[i][w+1][k],f[i][j][k]);
					f[i][j][w+1]=add(f[i][j][w+1],f[i][j][k]);
				}
			}
	int ans=0;
	fo(i,0,n)fo(j,0,n)ans=add(ans,f[i][j][n]);
	fo(i,0,n)fo(k,0,n)ans=add(ans,f[i][n][k]);
	fo(j,0,n)fo(k,0,n)ans=add(ans,f[n][j][k]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 221056
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <utility>

using namespace std;


int main() {
    string s;
    cin>>s;
    
    int judge=0;
    for(int i=0;i<s.size()-1;i++){
        if(s.at(i)==s.at(i+1)) judge++;
    }
    
    if(judge==0){
        cout<<"Good"<<endl;
    }
    else{
        cout<<"Bad"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
H,W=map(int,input().split())
a=list(sys.stdin)

q,w=[1]*H,[1]*W
for i in range(H):
    for j in range(W):
        if a[i][j]=='#':
            q[i]=w[j]=0

ans=''
for i in range(H):
    if q[i]:
        continue
    row=''
    for j in range(W):
        if w[j]:
            continue
        row+=a[i][j]
    ans+=row+'\n'
    

print(ans)


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ff first
#define ss second
#define rev(a) a.rbegin(),a.rend()
#define all(a) a.begin(),a.end()
#define pi pair<int,int>
#define vii vector<pi>
#define size(a)  (int)(a.size())
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define debug(...) cerr<<" ["<<#__VA_ARGS__<<": "<<(__VA_ARGS__)<<"] ";
#define debugv(...) for(int i=0; i<size(__VA_ARGS__); i++) cerr<<" ["<<#__VA_ARGS__<<i<<": "<<(__VA_ARGS__)[i]<<"] ";
const int mod = 1e8;
const int inf = 1e9+5;
const int inf64 = 1e18+5;
//           -------"Where is your Pen and Paper?"-------
int prime[10000001];
void sieve(){
    prime[1]=1;
    for(int i=2; i<10000001; i++){
        if(prime[i]==0){
            prime[i]=i;
            for(int j=2*i; j<10000001; j+=i){
                if(prime[j]==0) prime[j]=i;
            }
        }
    }
}
void solve(){
    int n;
    cin>>n;
    sieve();
    int ans=0;
    for(int i=1; i<=n; i++){
        int x=i;
        int t=1;
        int cnt=0;
        int prev=prime[x];
        while(x>1){
            if(prime[x]!=prev){
                prev=prime[x];
                t*=(cnt+1);
                cnt=1;
            }
            else{
                cnt++;
            }
            x/=prime[x];
        }
        t*=(cnt+1);
        //debug(t);
        ans+=i*t;
    }
    cout<<ans;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);  
    #endif
    */
    int test;
    //cin>>test;
    test=1;
    //int cse=1;
    while(test--){
         //cout<<"Case #"<<cse<<": ";
         solve();
         cout<<endl;
         //cse++;
    }
    return 0;
}

Measured memory_bytes: 81732
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A)+min(B)
for i in range(m):
    x,y,c=map(int,input().split())
    ans=min(ans,A[x-1]+B[y-1]-c)
print(ans)

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  int a = 0, b = 0, c = 0, d = 0;
  for(int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if(s == "AC") ++a;
    else if(s == "WA") ++b;
    else if(s == "TLE") ++c;
    else ++d;
  }
  cout << "AC x " << a << "\n";
  cout << "WA x " << b << "\n";
  cout << "TLE x " << c << "\n";
  cout << "RE x " << d << "\n";

}

Measured memory_bytes: 3656
/*
ID: duttonl1
TASK: Frog2.cpp 
LANG: C++
*/
#include <bits/stdc++.h>

#define pb push_back
#define fst first
#define snd second
#define DEBUGA(a, b) cout << "[ "; for (auto _x = (a); _x != (b); _x++) cout << *_x << " "; cout << "]"<< endl
#define DEBUG(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string>_it(_ss); err(_it, args); };cout << endl
#define fr(i,x) for (int i = 0; i < int(x); i++)
#define frab(i,a,b) for (int i = int(a); i < int(b); i++)
#define sz(x) ((int) (x).size())
void run();
int main() {
    std::ios::sync_with_stdio(false);
    run();
    return 0;
}

using namespace std;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "; ";
    err(++it, args...);
}


typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

#define INF 100000000000000

ll A[100005], dp[100005];
void run() {
    int n, k;
    cin >> n >> k;
    fr(i,n) cin >> A[i];
    dp[0] = 0;
    frab(i,1,n) {
        dp[i] = INF;
        for (int j = max(0, i-k); j < i; j++) {
            dp[i] = min(dp[i], dp[j] + abs(A[i] - A[j]));
        }
    }
    cout << dp[n-1] << endl;
}




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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void compute() {

}

int main() {
  int n;
  cin >> n;
  ll sum = 0;
  vector<ll> d(n);
  rep(i,n) {
    cin >> d[i];
    sum += d[i];
  }
  ll answer = 0;
  rep(i,n-1) {
    sum -= d[i];
    answer += ( d[i] * sum );
  }
  cout << answer << endl;
  compute();
  return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $n, $m);
for ($i=0; $i<$m; $i++) {
  fscanf(STDIN, '%d %d', $s[$i], $c[$i]);
  if (!$nums[$s[$i]]) {
    $nums[$s[$i]] = $c[$i];
  } else {
    if ($nums[$s[$i]] != $c[$i]) {
      echo '-1';
      exit;
    }
  }
}

for ($i=1; $i<=$n; $i++) {
  if ($nums[1] === 0 && $n != 1) {
    echo '-1';
    exit;
  }
  if ($nums[$i]) {
    echo $nums[$i];
  } else {
    if ($i == 1  && $n != 1) {
      echo '1';
    } else {
      echo '0';
    }
  }
}

Measured memory_bytes: 4728
c = 0
while 1:
  a, b = map(int, raw_input().split())
  if a == b == 0: break
  x = [i for i in range(a, b + 1) if (i % 4 == 0 and (i % 100 != 0 or i % 400 == 0))]
    
  if c: print
  if x == []: print "NA"
  else:
    for e in x: print e
  c = 1

Measured memory_bytes: 4300