akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();

        long ans = 0;
        for (int i = 1; i <= N; ++i) {
            for (int j = 1; j <= N/i; ++j) {
                int tmp = i * j;
                int C = N - tmp;
                if (C > 0 && tmp + C == N) ++ans;
            }
        }

        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() { return Double.parseDouble(next());}
}




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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

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

int main() {
  ll N, M;
  cin >> N >> M;
  priority_queue<int> q;
  for(ll i = 0LL; i < N; i++) {
    ll x;
    cin >> x;
    q.push(x);
  }
  for(ll i = 0; i < M; i++) {
    ll x = q.top();
    q.pop();
    q.push(x/2);
  }
  ll ans = 0LL;
  for(ll i = 0; i < N; i++){
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 892
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,m;cin>>n>>m;
    char a[50][50],b[50][50];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            cin>>b[i][j];
        }
    }
    for(int i=0;i<n-m+1;i++){
        for(int j=0;j<n-m+1;j++){
            bool abc=1;
            
            for(int x=i;x<m+i;x++){
                for(int y=j;y<m+j;y++){
                    if(a[x][y]!=b[x-i][y-j])
                    {
                        abc=0;
                        break;
                    }
                }
                if(abc==0)break;
            }
            
            if(abc==1){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<Endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------








Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cn1[100005];
int cn2[100005];
int mx1,mx2,n1,n2;
int main()
{
	int n;
	cin>>n;
	int a;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(i%2)
			cn1[a]++;
		else
			cn2[a]++;
	}
	for(int i=1;i<=100004;i++)
	{
		if(mx1<cn1[i])
		{
			mx1=cn1[i];
			n1=i;
		}
		if(mx2<cn2[i])
		{
			mx2=cn2[i];
			n2=i;
		}
	}
	if(n1==n2)
	{
		int mx22=0;
		for(int i=1;i<=100004;i++)
			if(i!=n1&&mx22<cn2[i])
				mx22=cn2[i];
		int mx12=0;
		for(int i=1;i<=100004;i++)
			if(i!=n2&&mx12<cn1[i])
				mx12=cn1[i];
		cout<<n-max((mx1+mx22),(mx12+mx2));
		return 0;
	}
	cout<<n-(mx1+mx2);

	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int x;
    cin >> x;
    int L[n ];
    for (int j=0;j< n;j++) {
        cin >> L[j];
    }

    int temp = 0;
    size_t i;
    for (i = 0; i < n ; i++) {
        temp += L[i];
        if(temp> x) {
            break;
        }
    }
    cout << i+1;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a, k;
    cin >> k >> n;
    vector<lli> v;
    for (lli i = 0; i < n; i++) {
        cin >> a;
        v.pb(a);
    }
    sort(all(v));
    lli mx = -1;
    for (lli i = 1; i < n; i++) {
        mx = max(mx, v[i] - v[i - 1]);
    }

    lli val = k - v[n - 1] + v[0];
    mx = max(mx, val);
    cout << k - mx << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 2420
n = int(input())

l = []

for _ in range(n):
    a,b = map(int, input().split())
    l.append((a+b,a,b))

l.sort()

ans = 0
for i in range(n):
    if i%2 == 0:
        ans += l[n-1-i][1]
    else:
        ans -= l[n-1-i][2]

print(ans)


Measured memory_bytes: 20992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009
using P = pair<int,int>;

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll dest = 0;
  if((a - b) % 2 == 0){
    dest = (a + b)/2;
    cout << b - dest << endl;
  }
  else{
    ll aup,adown,bup,bdown;
    aup = a-1;
    bup = b-1;
    adown = n - a;
    bdown = n - b;
    ll abup = min(aup,bup);
    ll abupans = abup + 1 + (b-a-1)/2;
    ll abdown = min(adown,bdown);
    ll abdownans = abdown + 1 + (b-a-1)/2;
    cout << min(abupans,abdownans) << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define pii pair<ll,int>
#define pip pair<int,pii>
#define ppi pair<pii,int> 
#define ppp pair<pii,pii>
#define pb push_back
#define ppb pop_back
#define pf push_fron
#define ppf pop_front
#define N 200003
#define inf (ll)(1e9+11)
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll mod=1e9+7;

signed main()
{
    warmup
    
    int l;
    cin>>l;
    ld d=l/3.0;
    cout<<fixed<<d*d*d;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair

const int INF = 1e9 + 7;

int main(){
    int n; cin >> n;
    vi p(n); cin >> p;

    int n_min = INF;
    int ans = 0;
    for(auto e:p){
        if(n_min > e){
            ans++;
            n_min = e;
        }
    }

    cout << ans << endl;

}

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

int main(void)
{
  int cheese_size;
  int length[3]; /* height, width, breadth */
  int n;
  int door_size, redius;
  
  while(1)
    {
      cin >> length[0] >> length[1] >> length[2];
      if(length[0] == 0 && length[1] == 0 && length[2] == 0) break;
      sort(length, length + 3);
      cheese_size = length[0] * length[0] + length[1] * length[1]; 
      
      cin >> n;
      
      for(int i = 0 ; i < n ; i++)
	{
	  cin >> redius;
	  door_size = (2 * redius) * (2 * redius); /* ツ陳シツ径 x ツ陳シツ径ツ。ツ青ウツ陛サツ形 */
	  
	  if(cheese_size < door_size) cout << "OK" << endl;
	  else cout << "NA" << endl;
	}
    }
  return 0;
}

Measured memory_bytes: 0
s = gets.chomp.split('').map(&:to_i)
MOD = 2019

s.reverse!

mods = Array.new(MOD, 0)

k = 1 # 何の位か
memo = 0 # 一つ前の位までの値をメモして使う
s.each do |ss|
  sss = memo + ss * k
  mod = sss % MOD
  mods[mod] += 1
  memo = mod # その位までのあまり
  k = (k * 10) % MOD # 次の位のための計算（modとってOK）
end

p mods[0] + mods.inject(0) {|result, mod| result + (mod * (mod-1)) / 2}


Measured memory_bytes: 26528
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

def Topo_sort(x,y):
	co = cl.Counter(n for m in x.values() for n in m)
	S = cl.deque([i for i in range(y) if co[i] == 0])
	while S:
		n = S.popleft()
		yield n
		for i in x[n]:
			co[i] -= 1
			if co[i] <= 0:
				S.append(i)
	if sum(co.values()) != 0:
		print(1)
		exit()
	else:
		print(0)
		exit()
# g = cl.dafaultdict(set)に有向グラフを作成し(g[~] != ~) リストが帰ってくる

v,e = m()

g = cl.defaultdict(set)

for i in range(e):
	s,t = m()
	g[s] |= {t}
a = list(Topo_sort(g,v))



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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

int get_leargest_rectangle(const vvi& grid) {
    int h = grid.size(), w = grid[0].size();

    // O(hw)
    vvi tile(h, vi(w + 1, 0));
    rep(i, 0, h) {
        rep(j, 0, w) {
            if (grid[i][j] == 1) {
                tile[i][j] = 0;
            } else {
                tile[i][j] = (i > 0 ? tile[i - 1][j] + 1 : 1);
            }
        }
    }

    int maxv = 0;
    rep(i, 0, h) {
        stack<pair<int, int>> S;

        rep(j, 0, w + 1) {
            // height, pos
            pair<int, int> rect = make_pair(tile[i][j], j);

            if (S.empty()) {
                S.push(rect);
            } else {
                if (S.top().first < rect.first) {
                    S.push(rect);
                } else if (S.top().first > rect.first) {
                    int xpos = i;
                    while (!S.empty() && S.top().first >= rect.first) {
                        pair<int, int> top = S.top();
                        S.pop();
                        xpos = top.second;
                        maxv = max(maxv, top.first * (rect.second - xpos));
                    }
                    rect.second = xpos;
                    S.push(rect);
                }
            }
        }
    }
    return maxv;
}

int main() {
    int h, w;
    scanf("%d %d", &h, &w);

    vvi grid(h, vi(w, 0));
    rep(i, 0, h) {
        rep(j, 0, w) { scanf("%d", &grid[i][j]); }
    }

    cout << get_leargest_rectangle(grid) << endl;
    return 0;
}


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

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

    rep(j, 2) for (int i = 9; i > 1; i--)
    {
        if (n % i == 0)
        {
            n /= i;
            break;
        }
    }

    if (n == 1)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int n,k,x,y;
	cin >> n >> k >> x >> y;
	int ans = min(n,k)*x + max(n-k,0)*y;
	P(ans);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int k, a, b;

int main() {
	fastio; cin >> k >> a >> b;
  FOR(i, a, b) if (i % k == 0) {
    cout << "OK"; return 0;
  }
  cout << "NG";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int k;
    cin >> k;
    vector<ll> vec;
    for (int i = 1; i <= 9; i++) vec.push_back(i);
    while (1) {
        if (k <= vec.size()) {
            cout << vec[k - 1] << endl;
            return 0;
        }
        k -= vec.size();
        vector<ll> old;
        swap(old, vec);
        for (ll x : old) {
            for (ll i = -1; i <= 1; i++) {
                ll d = x % 10 + i;
                if (d < 0 || d > 9) continue;
                ll nx = x * 10 + d;
                vec.push_back(nx);
            }
        }
    }
}

Measured memory_bytes: 1712
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <bitset>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define PR pair
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define REP(i, x, y)   for(int i = (int)(x); i <= (int)(y); i++)
#define FOR(i, x, y)   for(int i = (int)(x); i <  (int)(y); i++)
#define PER(i ,x, y)  for(int i = (int)(x); i >= (int)(y); i--)
#define CH	         ch = getchar()
#define Exit(...)    printf(__VA_ARGS__), exit(0)
#define dln()        fprintf(stderr,"\n")
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef double	  db;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI > VII;
typedef PR<int,int> PII;
typedef vector<PII> VPI;
const	int inf=2e9;
const	LL Inf=1e10;
const	int P=1e9+7;
const	int N=100005;

inline LL IN(){
	LL x = 0;
	int ch = 0, f = 0;
	for (CH; ch != -1 && (ch < 48 || ch > 57); CH) f = (ch == '-');
	for (; ch >= 48 && ch <= 57; CH) x = (x << 1) + (x << 3) + ch - '0';
	return f ? (-x) : x;
}
template<typename T> inline int chkmin(T &a, const T &b){if(b < a) return a = b, 1; return 0;}
template<typename T> inline int chkmax(T &a, const T &b){if(b > a) return a = b, 1; return 0;}

void renew(int &x, const int &y){
	x += y;
	if(x >= P) x -= P;
	if(x <  0) x += P;
}

int Pow(int x, int y, int p){
	int a = 1;
	for (; y; y >>= 1, x = (LL)x * x %p) if(y & 1) a=(LL)a * x%p;
	return a;
}

int n, a[N];
int ans = 1 << 30;

void work(int x, int l, int r){
	if(l > r) swap(l, r);
	if(l <= x && x <= r) chkmin(ans, x - 1);
}

int main(){
	scanf("%d", &n);
	FOR(i, 0, n) scanf("%d", a + i);
	sort(a, a + n);
	reverse(a, a + n);
	FOR(i, 0, n){
		int j = i;
		while(j < n && a[j] == a[i]) j ++;
		work(a[i], i, j);
		work(j, a[j], a[i]);
		i = j - 1;
	}
	int u = a[ans] - ans;
	int v = ans;
	while(a[v] > ans) v ++;
	v = v - ans;
	if((u & 1) && (v & 1)) printf("Second\n");
	else printf("First\n");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define IL inline
#define _ 1000005
#define ll long long
using namespace std ;

int n , f[_] , s[_] , p[_] , Ans ;
#define mod 1000000007

int main() {
	cin >> n ; 
	for(int i = 1; i <= n; i ++) {
		f[i] = ((i >= 3) ? p[i - 3] : 0) + 1 ;
		s[i] = (s[i - 1] + f[i]) % mod ; p[i] = (p[i - 1] + s[i]) % mod ; 
	}
	Ans = 0 ;
	for(int i = 1; i < n; i ++) Ans = (Ans + 1ll * f[i] * (n - 1) % mod * n % mod) % mod ;
	cout << (Ans + 1 + 1ll * f[n] * (n - 1) % mod) % mod  << endl ;
	return 0 ; 
}


Measured memory_bytes: 11904
#include <iostream>

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

    if(N % 1000 == 0) {
        std::cout << 0 << std::endl;
    }
    else {
        std::cout << 1000 - N % 1000 << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define fname "B"
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define bug(x) cerr << (#x) << " = " << (x) << '\n'
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<float, float> ff;
typedef pair<double, double> dd;

int main()
{
	if (fopen(fname".INP", "r")) {
		freopen(fname".INP", "r", stdin);
		freopen(fname".OUT", "w", stdout);
	}
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s, res;
	cin >> s;
	REP0(i, s.size()) {
		if (s[i] != 'B') res.pb(s[i]);
		else if (res.size()) res.popb();
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(M)]
ans = [-1] * N

if N == 1 and M == 0:
    print(0)
    exit()
elif N == 2 and M == 0:
    print(10)
    exit()
elif N == 3 and M == 0:
    print(100)
    exit()

for i in range(M):
    if ans[sc[i][0]-1] == -1:
        ans[sc[i][0]-1] = sc[i][1]
    else:
        if ans[sc[i][0]-1] != sc[i][1]:
            print(-1)
            exit()

if ans[0] == 0 and N != 1:
    print(-1)
    exit()

if ans[0] == -1:
    ans[0] = 1

for i in range(N):
    if ans[i] == -1:
        ans[i] = 0

ans_str = ""
for i in range(N):
    ans_str += str(ans[i])

print(int(ans_str))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}


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

    ll ans = 0;
    ll gcd[2*k +1]= {};

    for(ll i = k; i >= 2; i--){
    	ll divisors = k/i;
        gcd[i] =((power_mod(divisors,n)))%mod;
    	for(ll j = 2*i ;j<=k;j+=i){
             gcd[i] = (gcd[i]-gcd[j]+mod)%mod;
    	}    
    }
    ll total = power_mod(k,n);
    ll sum = 0;
    for(ll i = 2; i <= k; i++){
         sum =  (sum + gcd[i])%mod;
         ans =  (ans + (i*gcd[i])%mod)%mod;
    }
    ans = (total-sum +mod + ans)%mod;

    cout<<ans<<endl;
}

Measured memory_bytes: 5152
#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;
  string s;
  cin >> s;
  
  int ans=0;
  string t="000";
  rep(i,1000){
    int ti=0;
    rep(i,n){
      if(s[i]==t[ti]) ti++;
    }
    if(ti==3) ans++;
    if(t[2]=='9'){
      t[2]='0';
      if(t[1]=='9'){
        t[1]='0';
        t[0]++;
      }else t[1]++;
    }else t[2]++;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>

using namespace std;

#define M 1000000
#define L 14
char H[M][L];

int getchar(char s)
{
	if (s == 'A') return 1;
	else if (s == 'C') return 2;
	else if (s == 'G') return 3;
	else if (s == 'T') return 4;
	else return 0;
}

int getkey(char A[])
{
	int sum = 0;
	int p = 1;
	for (int i = 0; i < strlen(A); i++)
	{
		int tmp = getchar(A[i]);
		sum = sum + tmp*p;
		p = p * 5;
	}
	return sum;
}

int h1(int key)
{
	return key%M;
}

int h2(int key)
{
	return 1 + key % (M - 1);
}


int insert(char str[])
{
	int key=getkey(str);
	for (int i = 0;; i++)
	{
		int h = (h1(key) + i*h2(key))%M;
		if (strcmp(H[h], str) == 0)
			return 1;
		else if (strlen(H[h]) == 0)
		{
			strcpy(H[h], str);
			return 0;
		}	
	}
	return 0;
}

int find(char str[])
{
	int key = getkey(str);
	for (int i = 0;; i++)
	{
		int h = (h1(key) + i*h2(key)) % M;
		if (strcmp(H[h], str) == 0)
			return 1;
		else if (strlen(H[h]) == 0)
		{
			return 0;
		}
	}
	return 0;
}

int main()
{
	int N;
	cin >> N;
	char A[6], S[L];
	for (int i = 0; i < M; i++)
	{
		H[i][0] = '\0';
	}
	for (int i = 0; i < N; i++)
	{
		scanf("%s%s", A, S);
		if (A[0] == 'i')
		{
			insert(S);
		}
		else if (A[0] == 'f')
		{
			if (find(S))
				cout << "yes" << endl;
			else
				cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 16912
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a+b>=10) cout<<"error"<<'\n';
  else cout<<a+b<<'\n';
  return 0;
}


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

int energy(int, int);
int main(){
    int n;
    int *xData;
    cin >> n;
    xData = new int[n];
    int left = 100;
    int right = 1;
    for(int i=0; i<n; i++){
        cin >> xData[i];
        if(xData[i] < left){
            left = xData[i];
        }
        if(right < xData[i]){
            right = xData[i];
        }
    }
    int result = 0;
    for(int j=0; j<n; j++){
        result += energy(xData[j], left);
    }
    for(int i=left+1; i<=right; i++){
        int tr = 0;
        for(int j=0; j<n; j++){
            tr += energy(xData[j], i);
            if(tr > result) break;
        }
        if(tr < result) result = tr;
    }

    cout << result << endl;

    delete[] xData;
    return 0;
}

int energy(int x, int p){
    return (x-p) * (x-p);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};


int a[1000010];

int main(){
  int N;
  cin >> N;
  rep(i,N){
    cin >> a[i];
  }
  sort(a,a+N);
  if(a[N/2] - a[N/2-1] == 0) cout << 0 << endl;
  else cout << a[N/2] - a[N/2-1] << endl;
  
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define MOD 1000000007
#define PI acos(-1)
int main()
{
	IOS
	ll n,m,x;
	cin>>n>>m>>x;
	ll i;
	vector<ll> v[n];
	ll j;
	ll c;
	for(i=0;i<n;i++)
	{
		for(j=0;j<m+1;j++){
		cin>>c;
		v[i].push_back(c);
	 }
	}
	vector<int> vec;
	ll ans=1e10;
	for(i=0;i<pow(2,n);i++)
	{
		vec.clear();
	//	items.clear();
		for(j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				vec.pb(j);
			}
		}
	//	watch(vec.size());
		ll cost=0;
		ll items[m+1]={0};
		int k;

		for(k=0;k<vec.size();k++)
		{
		//	cout<<vec[k]<<" ";
			cost+=v[vec[k]][0];
			for(j=1;j<m+1;j++)
			items[j]+=v[vec[k]][j];
		}
		int flag=0;
		for(k=1;k<=m;k++)
		{
			if(items[k]<x)
			break;
		}
		if(k==m+1)
		ans=min(ans,cost);
	}
	if(ans==1e10)
	cout<<"-1";
	else
	cout<<ans;
}

Measured memory_bytes: 4100
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    print (YES if S[2] == S[3] and S[4] == S[5] else NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int inf=3e3+9;
ll a[inf],n;
pair<ll,ll> dp[inf][inf][2];

pair<ll,ll> solve(ll l,ll r,bool player){
    if(l>r)
        return make_pair(0,0);

    pair<ll,ll> &ret=dp[l][r][player];
    if(ret.first!=-1)
        return ret;

    if(player){
        pair<ll,ll>d=solve(l+1,r,0);
        d.first+=a[l];
        pair<ll,ll> f=solve(l,r-1,0);
        f.first+=a[r];
        if(f>d || (f.first==d.first && f.second<d.second))
            ret=f;
       else ret=d;
    }

    else{
        pair<ll,ll>d=solve(l+1,r,1);
        d.second+=a[l];
        pair<ll,ll> f=solve(l,r-1,1);
        f.second+=a[r];
        if(f<d || (f.first==d.first && f.second>d.second))
            ret=f;
       else ret=d;
    }

    return ret;
}

int main(){

    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];

    memset(dp,-1,sizeof(dp));
    pair<ll,ll> p=solve(1,n,1);
    cout<<p.first-p.second<<endl;
}


Measured memory_bytes: 283392
n,m = map(int,input().split())

ksl = []
for _ in range(m):
    ks = list(map(int,input().split()))
    ksl.append(ks[1:])

pl = list(map(int,input().split()))
ans = 0
for i in range(2**n):
    bit = [0] * n
    for j in range(n):
        if ((i >> j) & 1):
            bit[j] = 1
    
    for idx, ks in enumerate(ksl):
        p = 0
        for k in ks:
            p += bit[k-1]
        if p % 2 != pl[idx]:
            break
    else:
        ans += 1
            
print(ans)

Measured memory_bytes: 41072
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int n,m;
int P[100000],Y[100000];
vector<int> v[100001];
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>P[i]>>Y[i];
        v[P[i]].push_back(Y[i]);
    }
    for(int i=1;i<=n;i++)sort(v[i].begin(),v[i].end());
    long long ans;
    for(int i=0;i<m;i++){
        ans=(long long)P[i]*1000000+1;
        ans+=lower_bound(v[P[i]].begin(),v[P[i]].end(),Y[i])-v[P[i]].begin();
        printf("%012lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 7808
int main()
{
    int R;
    int G ;
    scanf ("%d",&R);
    scanf ("%d",&G);
    int i ;
    i = R+G;

    if (i>=24 ) {
        i=i-24;
        printf ("%d",i);

    }
    else{
        printf ("%d",i);

    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int n; cin>>n;
  	string s,x1,x2;cin>>s;
  	vector<char> a={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  	vector<int> d(n);
  	int ans=0;
  	
  	for (int i=1;i<n;i++){
      	vector<int> b(26);
  		vector<int> c(26);
    	x1=s.substr(0,i);
      	x2=s.substr(i,n-i);
     	//cout<<x1<<" "<<x2<<endl;
      
      for (int j=0;j<i;j++){
      	for(int k=0;k<26;k++){
        	if(a.at(k)==x1.at(j)){
            	b.at(k)++;
            }
        }
      }
     
      for (int j=0;j<n-i;j++){
      	for(int k=0;k<26;k++){
        	if(a.at(k)==x2.at(j)){
            	c.at(k)++;
            }
        }
      }
    
      for(int j=0;j<26;j++){
      	if(b.at(j)>=1 && c.at(j)>=1){
        	d.at(i)++;
        }
      }
    }
  
  for(int i=0;i<n;i++){
  	ans=max(ans,d.at(i));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, j, n) for (int i = j; i < (int)(n); i++)
#define brep(i, n) for (int i = n; i > 0; i--)
#define BREP(i, j, n) for(int i = n; i > j; i--)
#define TEST cout << "PASS" << endl
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 1e6 + 1e3 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
    int n;
    cin >> n;
    ll k;
    cin >> k;
    ll a[100000], copy_a[100000];
    rep(i, n){
        cin >> a[i];
        copy_a[i] = a[i];
    }
    vector<int> v;
    rep(i, 40){
        int cnt = 0;
        rep(j, n){
            if(copy_a[j] & 1) cnt++;
            copy_a[j] >>= 1;
        }
        if(cnt <= (n-1)/2 && pow(2, i) <= k) v.push_back(i);
    }
    reverse(all(v));
    ll u = 0;
    for(int x: v){
        if(pow(2, x) + u <= k) u += pow(2, x);
    }
    ll ans = 0;
    rep(i, n){
        ans += u^a[i];
    }
    cout << ans << endl;

}

Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> A(2 * n);
	int ans = 0;
	for (int i = 0; i < 2 * n; ++i) scanf("%d", &A[i]);
	sort(A.begin(), A.end());
	for (int i = 0; i < 2 * n; i += 2) ans += A[i];
	printf("%d\n", ans);
}


Measured memory_bytes: 256
class Dice:
    def __init__(self, p):
        self.y = [p[0], p[1], p[5], p[4]]
        self.x = [p[0], p[2], p[5], p[3]]
        self.z = [p[1], p[2], p[4], p[3]]
    def roll(self, c):
        if c == 'y':
            self.y.append(self.y.pop(0))
            self.x[0] = self.y[0]
            self.x[2] = self.y[2]
            self.z[0] = self.y[1]
            self.z[2] = self.y[3]
        elif c == 'x':
            self.x.append(self.x.pop(0))
            self.y[0] = self.x[0]
            self.y[2] = self.x[2]
            self.z[1] = self.x[1]
            self.z[3] = self.x[3]
        elif c == 'z':
            self.z.append(self.z.pop(0))
            self.x[1] = self.z[1]
            self.x[3] = self.z[3]
            self.y[1] = self.z[0]
            self.y[3] = self.z[2]
    def num(self, n):
        n = n - 1;
        pos_y = [0, 1, 5, 4]
        pos_x = [0, 2, 5, 3]
        if n in pos_y:
            return self.y[pos_y.index(n)]
        else:
            return self.x[pos_x.index(n)]
    def same(self, other):
        for _ in range(4):
            if self == other:
                return True
            other.roll('x')
            for _ in range(4):
                if self == other:
                    return True
                other.roll('y')
                for _ in range(4):
                    if self == other:
                        return True
                    other.roll('z')
        return False
    def __eq__(self, other):
        for i in range(1,7):
            if (self.num(i) != other.num(i)):
                return False
        return True

n = int(input())
dices = []
for _ in range(n):
    dices.append(Dice([int(i) for i in input().split()]))

yes = all([not dices[0].same(other) for other in dices[1:]])
print('Yes' if yes else 'No')



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

long long a, b, n, k, sum[100500];
int main(){
	cin >> n >> k;
	for (long long i = 1; i <= n; i++){
		cin >> a >> b;
		sum[a] += b;
	}
	long long cnt = 1, rem = 0;
	while (k > 0){
		k -= sum[cnt];
		if (k <= 0){
			rem = cnt;
		}
		cnt++;
	}
	cout << rem << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = unsigned long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;
int main() {
  ll k;
  in(k);
 if(k%2==0)out(k*k/4);
  else out((k-1)*(k+1)/4);
}

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

#define sz(x) (int)(x.size())
#define FOR(i,L,R) for(int i = L; (L <= R? i <= R : i >= R); (L <= R? i += 1 : i -= 1))
#define int long long

const int N = 2e5 + 2, inf = 1e18;

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

    int n;
    cin >> n;
    int a[n];
    int ans = 0;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) if(a[i] != a[j]) {
            for(int k = j + 1; k < n; k++) if(a[k] != a[j] && a[k] != a[i]) {
                vector<int> all = {a[i], a[j], a[k]};
                sort(all.begin(), all.end());
                if(all[0] + all[1] > all[2]) ++ans;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b){
    return b==0 ? a : gcd(b, a%b);
}

int main(){
    int n;
    cin >> n;
    ll x;
    cin >> x;
    for(int i = 0; i < n-1; i++){
        ll y;   cin >> y;
        x = gcd(x, y);
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int N ;
  string S ;
  cin >> N ;
  cin >> S ;
  int M = S.size() ;
  string A ;
  A[0] = 'A' ;A[1] = 'B' ;A[2] = 'C' ;A[3] = 'D' ;
  A[4] = 'E' ;A[5] = 'F' ;A[6] = 'G' ;A[7] = 'H' ;A[8] = 'I' ;A[9] = 'J' ;
  A[10] = 'K' ;A[11] = 'L' ;A[12] = 'M' ;A[13] = 'N' ;A[14] = 'O' ;
  A[15] = 'P' ;A[16] = 'Q' ;A[17] = 'R' ;A[18] = 'S' ;A[19] = 'T' ;A[20] = 'U' ;
  A[21] = 'V' ;A[22] = 'W' ;A[23] = 'X' ;A[24] = 'Y' ;A[25] = 'Z' ;
  A[26] = 'A' ;A[27] = 'B' ;A[28] = 'C' ;A[29] = 'D' ;
  A[30] = 'E' ;A[31] = 'F' ;A[32] = 'G' ;A[33] = 'H' ;A[34] = 'I' ;A[35] = 'J' ;
  A[36] = 'K' ;A[37] = 'L' ;A[38] = 'M' ;A[39] = 'N' ;A[40] = 'O' ;
  A[41] = 'P' ;A[42] = 'Q' ;A[43] = 'R' ;A[44] = 'S' ;A[45] = 'T' ;A[46] = 'U' ;
  A[47] = 'V' ;A[48] = 'W' ;A[49] = 'X' ;A[50] = 'Y' ;A[51] = 'Z' ;
  rep(i,M){
    rep(j,26){
    if(S[i] == A[j] ) cout << A[j+N] ;
    	}
      }
}

Measured memory_bytes: 256
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
#print(a1,a2,a3)
a=[]
a.append(a1)
a.append(a2)
a.append(a3)
#print(a)
#print(a[0][0],a[1][1],a[2][2])
n=int(input())
b=[]
for i in range(n):
  b.append(int(input()))
#print(b)
for i in range(n):
  for m in range(3):
    for n in range(3):
      if a[m][n]==b[i]:
        a[m][n]=0
yes=0
#print(a)
for m in range(3):
  if a[m][0]+a[m][1]+a[m][2]==0:
    yes=1
for n in range(3):
  if a[0][n]+a[1][n]+a[2][n]==0:
    yes=1
if a[0][0]+a[1][1]+a[2][2]==0:
  yes=1
if a[0][2]+a[1][1]+a[2][0]==0:
  yes=1
if yes==1:
  print("Yes")
else:
  print("No")

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int h,w;
string c[333];
int dp[333][333];

int table[333][333];

int main(){
	cin.sync_with_stdio(false);
	cin>>h>>w;
	rep(i,h)cin>>c[i];
	int res=0;
	rep(i,w-1){//i,i+1
		memset(table,0,sizeof(table));
		repl(j,1,h+1)repl(k,1,h+1){
			table[j][k]=table[j-1][k-1];
			if(c[j-1][i]==c[k-1][i+1])table[j][k]++;
		}
		rep(j,h+1)rep(k,h+1)dp[j][k]=INF;
		dp[h][h]=0;
		for(int j=h;j>=0;j--)for(int k=h;k>=0;k--){
			if(dp[j][k]==INF)continue;
			if(j-1>=0)minch(dp[j-1][k],dp[j][k]+table[j][k]);
			if(k-1>=0)minch(dp[j][k-1],dp[j][k]+table[j][k]);
		}
		res+=dp[0][0];
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

// M * (M-1)^(N-1-K) * N-1 C K
int main(int argc, const char * argv[]) {
    ll H,P; cin >> H >>P;
    if(H%P==0){
        cout << H/P << endl;
    }else{
        cout << H/P + 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
int main()
{
    int n;
    cin >> n;
    vector<int> c(n),s(n),f(n);
    for(int i = 0; i < n-1; i++) cin >> c[i] >> s[i] >> f[i];
    for(int i = 0; i < n-1; i++){
        int res = s[i]+c[i];
        for(int j = i+1; j < n-1; j++){
            if(res <= s[j]) res = s[j];
            else res = s[j]+(res-s[j]-1)/f[j]*f[j]+f[j];
            res += c[j];
        }
        cout << res << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        int[] vs = new int[n];
        for (int i = 0; i < n; i++) {
            vs[i] = sc.nextInt();
        }

        int ans = 0;
        for (int l = 0; l <= Math.min(n, k); l++) for (int r = 0; l + r <= Math.min(n, k); r++) {
            for (int in = 0; in <= l + r && in + l + r <= k; in++) {
                PriorityQueue<Integer> q = new PriorityQueue<>();
                int sum = 0;
                for (int i = 0; i < l; i++) {
                    sum += vs[i];
                    q.add(vs[i]);
                }
                for (int i = 0; i < r; i++) {
                    sum += vs[n - i - 1];
                    q.add(vs[n - i - 1]);
                }
                for (int i = 0; i < in; i++) {
                    int t = q.remove();
//                    debug(t);
                    sum -= t;
                }
//                debug(l, r, in, sum);
                ans = Math.max(ans, sum);
            }
        }
        System.out.println(ans);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 44216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] gems = new int[N];
		for (int i = 0; i < N; i++) {
			if (sc.hasNext()) {
				gems[i] = sc.nextInt();
			}
		}
		
		int[] costs = new int[N];
		for (int i = 0; i < N; i++) {
			if (sc.hasNext()) {
				costs[i] = sc.nextInt();
			}
		}
		
		int[] values = new int[N];
		for (int i = 0; i < N; i++) {
			values[i] = gems[i] - costs[i];
		}
		int result = 0;
		for (int i = 0; i < N; i++) {
			values[i] = gems[i] - costs[i];
			if (values[i] > 0) {
				result += values[i];
			}
		}
		
		System.out.println(result);
		
	} 
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

int H,W;
vector<string> fi;
int Left[2100][2100],Right[2100][2100],Up[2100][2100],Down[2100][2100];

int main(void){
    cin>>H>>W;
    fi.resize(H);
    for(int i=0;i<H;i++) cin>>fi[i];
    
    for(int i=0;i<H;i++){
        int cur=0;
        for(int j=0;j<W;j++){
            if(fi[i][j]=='#') cur=0;
            else cur++;
            Left[i][j]=cur;
        }
    }
    for(int i=0;i<H;i++){
        int cur=0;
        for(int j=W-1;j>=0;j--){
            if(fi[i][j]=='#') cur=0;
            else cur++;
            Right[i][j]=cur;
        }
    }
    for(int j=0;j<W;j++){
        int cur=0;
        for(int i=0;i<H;i++){
            if(fi[i][j]=='#') cur=0;
            else cur++;
            Up[i][j]=cur;
        }
    }
    for(int j=0;j<W;j++){
        int cur=0;
        for(int i=H-1;i>=0;i--){
            if(fi[i][j]=='#') cur=0;
            else cur++;
            Down[i][j]=cur;
        }
    }
    int res=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(fi[i][j]=='#') continue;
            chmax(res,Left[i][j]+Right[i][j]+Up[i][j]+Down[i][j]-3);
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 72448