akhauriyash/Code-Regression huggingface dataset:
#include<cstdlib>
#include<vector>
#include<string>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<cstdio>
#include<iostream>
#include<vector>
#define MAXN 1000
using namespace std;
typedef long long ll;
char data[6000];
ll kindex[26][5100]={0};
ll same[26][5100]={0};
ll lens[26][5100]={0};
ll true_lens[26][5100]={0};
ll cnt[26]={0};
ll ans=0;
int main()
{
	ios::sync_with_stdio(false);
	//freopen("../in", "r", stdin);
	//freopen("../out", "w", stdout);
	ll n;
	cin >> n;
	cin >> data;
	//n = strlen(data);
	//cout<<n<<endl;
	ll mymax = 0;
	for (ll i = 0; i < n; i++)
	{
		kindex[data[i] - 'a'][cnt[data[i] - 'a']] = i;
		cnt[data[i] - 'a']++;
	}
	for (ll i = 0; i < 26; i++)
		for (ll k = 1; k < cnt[i]; k++)
		{
			ll len = 1;
			while  (data[kindex[i][0] + len] == data[kindex[i][k] + len])
			{
				len++;
			}
			lens[i][k] = len;//不相等处
			if(kindex[i][0] + len>kindex[i][k])
			{
				ans=max(ans,kindex[i][k]-kindex[i][0]);
			}
			else
				ans=max(ans,len);
		}
	for (ll i = 0; i < 26; i++)
		for (ll j = 1; j < cnt[i]; j++)
			for (ll k = j + 1; k < cnt[i]; k++)
			{
				if (same[i][j] == same[i][k] )
				{
					if (lens[i][j] == lens[i][k])
					{
						ll len = lens[i][k];
						while (data[kindex[i][j] + len] == data[kindex[i][k] + len])
						{
							len++;
						}
						lens[i][k] = len;
						same[i][k] = j;
						if(kindex[i][j] + len>kindex[i][k])
						{
							ans=max(ans,kindex[i][k]-kindex[i][j]);
						}
						else
							ans=max(ans,len);
					}
				}
			}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2432
n, k = map(int, input().split())
s = list(input())
if s[k-1] == "A":
    s[k-1] = "a"
elif s[k-1] == "B":
    s[k-1] = "b"
elif s[k-1] == "C":
    s[k-1] = "c"
print("".join(s))

Measured memory_bytes: 9124
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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 main(){
    int n, k; cin >> n >> k;
    vector<ll> A(n); rep(i, n) cin >> A[i];

    ll ng = 0, ok = INF;
    while(ok - ng > 1){
        ll mid = (ok + ng) / 2;
        //k回以内の操作でいずれの丸太も長さをmid以下にできるか
        int cnt = 0;
        rep(i, n){
            double tmp = A[i] / (double)mid;
            int num = ceil(tmp) - 1;
            cnt += num;
        }
        if(cnt <= k)ok = mid;
        else ng = mid;
    }
    cout << ok << ln;
}
    


Measured memory_bytes: 4828
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;


void print(string s, int a, int b){
    string tmp;
    tmp = s.substr(a,b-a+1);
    cout << tmp << endl;
}

string reverse(string s, int a, int b){
    string first,tmp,end;
    first = s.substr(0,a);
    tmp = s.substr(a,b-a+1);
    end = s.substr(b+1,s.size()-b);
    
    reverse(tmp.begin(),tmp.end());

    return first+tmp+end;
}

string replace(string s, int a, int b, string p){
    string first,end;
    first = s.substr(0,a);
    end = s.substr(b+1,s.size()-b);

    return first+p+end;
}


int main(int argc, const char * argv[]) {


    string str;
    cin >> str;
    
    int n;
    cin >> n;

    for(int i=0; i<n; i++){
        string op;
        cin >> op;
        int a,b;
        string p;
        cin >> a >> b;
        if(op == "print"){
            print(str,a,b);
        }
        else if(op == "reverse"){
            str = reverse(str,a,b);
        }
        else if(op == "replace"){
            string p;
            cin >> p;
            str = replace(str,a,b,p);
        }
        
        
    }
    return 0;
}



Measured memory_bytes: 3176
# LIS on Tree

from collections import deque
import bisect
import sys
sys.setrecursionlimit(10**7)

N = int(input())
V = list(map(int, input().split()))
V.insert(0, 0)
visited = [False for i in range(N+1)]
inf = 10**18
dp = [inf for i in range(N+1)]
ans = [-1 for i in range(N+1)]
stack = deque()

G = [[] for i in range(N+1)]
for _ in range(N-1):
    u, v = map(int, input().split())
    G[u].append(v)
    G[v].append(u)


def dfs(s_node):
    visited[s_node] = True
    # dp値の更新
    value = V[s_node]
    index = bisect.bisect_left(dp, value)
    old_value = dp[index]
    dp[index] = value
    ans[s_node] = bisect.bisect_right(dp, inf-1)
    stack.append((index, old_value, value))
    for child in G[s_node]:
        if visited[child] == False:
            dfs(child)
    # 帰りがけにバックトラックを行う
    index, old_value, value = stack.pop()
    dp[index] = old_value


dfs(1)

for i in range(1, N+1):
    print(ans[i])

Measured memory_bytes: 567824
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 304, mod = (int) 0;
int a[N][N], cnt[N], mark[N];
int main() {
	int n, m;
	cin >> n >> m;
	for (int p = 0; p < n; ++p) {
		for (int j = 0; j < m; ++j) {
			cin >> a[p][j];
			--a[p][j];
		}
	}
	int res = n;
	for (int turn = 0; turn < m; ++turn) {
		memset(cnt, 0, sizeof cnt);
		for (int person = 0; person < n; ++person) {
			for (int event = 0; event < m; ++event) {
				int id = a[person][event];
				if (!mark[id]) {
					cnt[id]++;
					break;
				}
			}
		}
		int most = 0;
		while (mark[most]) ++most;
		for (int event = 0; event < m; ++event) {
			if (!mark[event] && cnt[most] < cnt[event]) {
				most = event;	
			}
		}
		res = min(res, cnt[most]);
		mark[most] = 1;
	}
	cout << res << endl;
}




Measured memory_bytes: 640
def management(N,array):
  res = [0]*N
  for i in range(len(array)):
    res[array[i]-1] += 1
  for j in range(len(res)):
    print(res[j])

if __name__ == '__main__':
  N = int(input())
  array = list(map(int,input().split()))
  management(N,array)

Measured memory_bytes: 32372
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <algorithm>
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1 |1
#define lowbit(x) x&(-x)
#define LL long long
using namespace std;

int main()
{
    int x, a, b;
    while(~scanf("%d%d%d", &x, &a, &b)) {
        printf("%s\n", abs(x-a)>abs(x-b)?"B":"A");
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(n);
        llin(k);
        if(k==1){
        sal(0);
        }else{
                sal(n-k);
        }
}


Measured memory_bytes: 256
use std::cmp;
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;
use std::string::String;

const MAX: isize = 2147483647;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn dijkstra(s: usize, n: usize, g: &Vec<Vec<(usize, isize)>>) -> Vec<isize> {
    let mut d: Vec<isize> = vec![MAX; n];
    d[s] = 0;
    let mut pq = std::collections::BinaryHeap::<(isize, usize)>::new();
    pq.push((d[s]*(-1), s));

    while !pq.is_empty() {
        let (mut tmpd, now): (isize, usize) = pq.pop().unwrap();
        if d[now] < tmpd {continue;}
        for &(to, cost) in &g[now] {
            if d[to] > d[now] + cost {
                d[to] = d[now] + cost;
                pq.push((d[to]*(-1), to));
            }
        }
    }
    d
}


fn main() {
    let (n, m, s): (usize, usize, usize) = (read(), read(), read());
    let mut g: Vec<Vec<(usize, isize)>> = Vec::new();
    //g.resize(5, Vec::new()); //g = [[], [], [], [], []];
    //println!{"{:?}", g};
    g.resize(n, Vec::new());
    for i in 0..m {
        let (u, v, c): (usize, usize, isize) = (read(), read(), read());
        //let (mut u, mut v, c): (usize, usize, usize) = (read(), read(), read());
        g[u].push((v, c));
    }
    //println!{"{:?}", g};
    let dist: Vec<isize> = dijkstra(s, n, &g);
    //println!{"{:?}", dist};
    for d in dist {
        if d == MAX {
            println!{"INF"};
        }
        else {
            println!{"{}", d};
        }
    }
}



Measured memory_bytes: 23356
#include<bits/stdc++.h>
using namespace std;
const int maxn=101000;

struct edge{
	int to,nxt;
}e[maxn<<1];
int head[maxn],tot,n,m,q,dis[maxn],col[maxn];
void add(int x,int y)
{
	e[++tot].to=y;
	e[tot].nxt=head[x];
	head[x]=tot;
}

struct opte{
	int p,d,c;
}opt[maxn];

void dfs(int x,int d,int c)
{
	if(dis[x]>=d)return ;//剪枝 
	dis[x]=d;
	if(!col[x])col[x]=c;//最后一次的颜色 
	if(!d)return ;
	for(int i=head[x];i;i=e[i].nxt)
	{
		int y=e[i].to;
		dfs(y,d-1,c);
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
	}
	memset(dis,-1,sizeof(dis));
	scanf("%d",&q);
	for(int i=1;i<=q;i++)scanf("%d%d%d",&opt[i].p,&opt[i].d,&opt[i].c);
	for(int i=q;i>=1;i--)
		dfs(opt[i].p,opt[i].d,opt[i].c);
	for(int i=1;i<=n;i++)cout<<col[i]<<"\n";
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> table((H+2), vector<char>((W+2), '#'));

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> table.at(i+1).at(j+1);
    }
  }

  for (int i = 0; i < H+2; i++) {
    for (int j = 0; j < W+2; j++) {
      cout << table.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
#define rep(x, y, a) for (ll x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

typedef vector<int> vi;
typedef vector<pii> vpii;
namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int x, y;
    cin >> x >> y;
    if (x * 2 <= y && (y - x * 2) % 2 == 0 && x * 4 >= y) put("Yes");
    else put("No");
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;
    while (q--) solve();
}





Measured memory_bytes: 3656
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<ll>> G(N, vector<ll>(D));
    rep(i, N) {
        rep(j, D) { cin >> G[i][j]; }
    }

    ll ans = 0;
    rep(i, N) {
        for (int j = i + 1; j < N; j++) {
            if (i == j)
                continue;
            ll tmp = 0;
            rep(k, D) { tmp += (G[i][k] - G[j][k]) * (G[i][k] - G[j][k]); }
            for (int l = 0; l * l <= tmp; l++) {
                if (l * l == tmp)
                    ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007

long long bipow(long long n, long long m) {
    if (m == 0) return 1;
    if (m % 2 == 0) {
        n = (n * n) % MOD;
        return bipow(n, m / 2) % MOD;
    } else
        return (n * bipow(n, m - 1)) % MOD;
}

vector<long long> fact_num, fact_den;

void set_table(long long N, vector<long long> &fact_num, vector<long long> &fact_den){
    fact_num.resize(N+1, 0);
    fact_den.resize(N+1, 0);
    vector<long long> fact_denpow(N+1, 0);

    fact_num[0] = 1;
    for(long long i=1; i<=N; i++) fact_num[i] = (fact_num[i-1] * i) % MOD;

    for(long long i=0; i<=N; i++) fact_denpow[i] = bipow(i, MOD-2);
    fact_den[0] = 1;
    for(long long i=1; i<=N; i++) fact_den[i] = (fact_den[i-1] * fact_denpow[i]) % MOD;
}

// mCn
long long comb(const vector<long long> &fact_num, const vector<long long> &fact_den, long long m, long long n){
    return ((fact_num[m] * fact_den[n]) % MOD * fact_den[m-n]) % MOD;
}

long long solve(long long N, long long M){
    long long ret = 0;
    for(long long i=1; i<N; i++){
        ret += (i*(N-i)) % MOD;
        ret %= MOD;
    }
    ret = (ret * M*M) % MOD;
    return ret;
}

int main(){
    long long N, M, K;
    cin >> N >> M >> K;
    set_table(N*M+10, fact_num, fact_den);

    long long ans = (solve(N, M) + solve(M, N)) % MOD;
    ans = (ans * comb(fact_num, fact_den, N*M-2, K-2)) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
H, W, D = [int(x) for x in input().split()]
A = [[int(x) for x in input().split()] for line in range(H)]
Q = int(input())

Amap = {A[i][j]: (i, j) for i in range(H) for j in range(W)}


def move_mp(pos1, pos2):
    return abs(pos1[0] - pos2[0]) + abs(pos1[1] - pos2[1])


mp_list = [0 for i in range(H * W + 1)]

for i in range(D + 1, H * W + 1):
    mp_list[i] = mp_list[i - D] + move_mp(Amap[i - D], Amap[i])

for i in range(Q):
    L, R = [int(x) for x in input().split()]

    print(mp_list[R] - mp_list[L])
        


Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
#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
typedef long long ll;
typedef long double ld;
int ans[505][505];
int main() {
	int k;
	scanf("%d", &k);
	if (k <= 5) {
		printf("%d\n", k);
		for (int i = 1; i <= k; ++i) {
			for (int j = 1; j <= k; ++j)
				printf("%d ", i);
			printf("\n");
		}
		return 0;
	}
	int n = (k + 1) / 2;
	if (n % 2) ++n;
	printf("%d\n", n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			int a = i + 1, b = i + n + 1;
			if (b > k) b = a;
			ans[(i - j + n) % n][j] = (j & 1) ? a : b;
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j)
			printf("%d ", ans[i][j]);
		printf("\n");
	}
}


Measured memory_bytes: 2176
#include<stdio.h>
int main(){
  int n,q,i,ans=0,j,flag=0;
  scanf("%d",&n);
  int s[n];
  for(i=0;i<n;i++){
  scanf("%d",&s[i]);

  }
  scanf("%d",&q);
  int t[q];
   for(i=0;i<q;i++){
  scanf("%d",&t[i]);
  }


     
   
     for(i=0;i<q;i++){
     j=0;
     flag=0;
     while(j<n){
       if(t[i]==s[j]){
	 ans=ans+1;
	 flag=1;
       }
       if(flag==1){j=n;}
       j++;
     }
     
   }
   
     printf("%d\n",ans);
   return 0;
}



Measured memory_bytes: 2124
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 255000;
vector < int > g[N];
int c[N];
int used[N], n, m;
void dfs(int v){
    used[v] = 1;
    for (auto u: g[v]){
        if (used[u]){
            if (c[u] == c[v]){
                cout << n * (n - 1) / 2 - m;
                exit(0);
            }
            continue;
        }
        c[u] = c[v] ^ 1;
        dfs(u);
    }
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1);
    int x = 0;
    int y = 0;
    for (int i = 1; i <= n; i++)
    if (c[i] == 0){
        x++;
    } else{
        y++;
    }
    cout << x * y - m;
}


Measured memory_bytes: 12928
using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#define N 2010
int n,m;
struct EDGE{
	int to;
	EDGE *las;
};
struct Graph{
	EDGE *last[N*2];
	void link(int u,int v){
		EDGE *nw=new EDGE;
		*nw={v,last[u]};
		last[u]=nw;
	}
} G,F,L;
int d[N];
struct edge{
	int u,v;
} og[N],p[N*2];
int np;
#define Lto(ei) (p[ei->to].u^p[ei->to].v^(x))
void Flk(int u,int v,int ty){
	F.link(u,v*ty);
	F.link(v,u*ty);
}
int anss;
int ans[N*2];
set<pair<int,int> > s;
int fa[N],dep[N];
void dfs(int x){
	dep[x]=dep[fa[x]]+1;
	for (EDGE *ei=G.last[x];ei;ei=ei->las)
		if (ei->to!=fa[x]){
			fa[ei->to]=x;
			dfs(ei->to);
		}
}
int lca(int a,int b){
	if (dep[a]<dep[b]) swap(a,b);
	for (int k=dep[a]-dep[b];k;--k)
		a=fa[a];
	for (;a!=b;a=fa[a],b=fa[b]);
	return a;
}
void topu(){
	static int q[N];
	static bool vis[N];
	int head=1,tail=0;
	for (int i=1;i<=n;++i)
		if (d[i]==1)
			q[++tail]=i;
	while (head<=tail){
		int x=q[head++],y=0;
		vis[x]=1;
		for (EDGE *ei=G.last[x];ei;ei=ei->las)
			if (!vis[ei->to])
				y=ei->to;
		if (!y) continue;
		if (--d[y]==1)
			q[++tail]=y;
		int cnt=0;
		for (EDGE *ei=L.last[x];ei;ei=ei->las)
			if (!vis[Lto(ei)])
				cnt++;
		if (cnt==1 || s.find(make_pair(x,y))!=s.end()){
			anss++;
			for (EDGE *ei=L.last[x];ei;ei=ei->las)
				if (!vis[Lto(ei)]){
					(p[ei->to].u==x?p[ei->to].u:p[ei->to].v)=y;
					L.link(y,ei->to);
				}
		}
		else if (cnt>1){
			EDGE *e1=NULL,*e2=NULL,*ei;
			for (ei=L.last[x];ei && !e2;ei=ei->las)
				if (!vis[Lto(ei)]){
					if (!e1) e1=ei;
					else e2=ei;
				}
			for (;ei;ei=ei->las)
				if (!vis[Lto(ei)]){
					(p[ei->to].u==x?p[ei->to].u:p[ei->to].v)=y;
					L.link(y,ei->to);
				}
			fa[x]=0,dfs(x);
			int a=Lto(e1),b=Lto(e2),z=lca(a,b);
			p[++np]={a,b};
			L.link(a,np),L.link(b,np);
			Flk(np,e1->to,p[e1->to].u==a?1:-1);
			Flk(e1->to,e2->to,(int(p[e1->to].u==x) ^ int(p[e2->to].u==x))?1:-1);
			for (;z!=x;z=fa[z]){
				if (s.find(make_pair(z,fa[z]))!=s.end())
					continue;
				s.insert(make_pair(z,fa[z]));
				s.insert(make_pair(fa[z],z));
				anss++;
			}
			anss++;
		}
	}
}
void color(int x){
	for (EDGE *ei=F.last[x];ei;ei=ei->las){
		int y=abs(ei->to);
		if (!ans[y]){
			ans[y]=(ei->to>0?ans[x]:-ans[x]);
			color(y);
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<n;++i){
		int u,v;
		scanf("%d%d",&u,&v);
		G.link(u,v),G.link(v,u);
		d[u]++,d[v]++;
	}
	for (int i=1;i<=m;++i){
		int x,y;
		scanf("%d%d",&x,&y);
		p[++np]={x,y};
		og[np]=p[np];
		L.link(x,np),L.link(y,np);
	}
	topu();
	printf("%d\n",anss);
	for (int i=1;i<=m;++i){
		if (ans[i]==0)
			ans[i]=1,color(i);
		if (ans[i]==1)
			printf("%d %d\n",og[i].u,og[i].v);
		else
			printf("%d %d\n",og[i].v,og[i].u);
	}
	return 0;
}

Measured memory_bytes: 40988
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
int main() {
	int a;
	cin >> a;
	int b, c, d, e;
	e = a % 10;
	a = a / 10;
	d = a % 10;
	a = a / 10;
	c = a % 10;
	b= a / 10;
	if (b != c && c != d && d != e) {
		cout << "Good" << endl;
	}
	else{
		cout << "Bad" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define one_peace ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int main()
{
    one_peace;
    double a;
    int b,c,c2;
    cin>>a;
    b=a/1.08;


        c2=b*1.08;
    if(c2==a){cout<<b;return 0;}
    c=(b+1)*1.08;
    if(c==a){cout<<b+1;}


    else{cout<<":(";}

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    //500 100 50
    int count=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if((i*500+j*100+k*50)==x)count++;
            }
        }
    }
    cout<<count;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// AtCoder_A
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int D = sc.nextInt();
		int T = sc.nextInt();
		int S = sc.nextInt();
		int ans = 0;

		if(S*T >= D) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}


Measured memory_bytes: 35892
nums={"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}
while True:
    try:
        s=input()
    except:
        break
    ans=nums[s[0]]
    for i in range(1,len(s)):
        if nums[s[i-1]]<nums[s[i]]:
            ans-=2*nums[s[i-1]]
        ans+=nums[s[i]]
    print(ans)
        

Measured memory_bytes: 7356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P ,ll> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, cnt[3]{}, ans = 0;
    string s;
    cin >> n;
    REP(i,n){
        cin >> s;
        for(int j=0;j<int(s.size())-1;j++){
            if(s[j] == 'A' && s[j+1] == 'B') ans++;
        }
        if(s.front() == 'B' && s.back() == 'A'){
                cnt[0]++;
            }
            else if(s.front() == 'B'){
                cnt[1]++;
            }
            else if(s.back() == 'A'){
                cnt[2]++;
            }
    }
    //cout << ans << endl;
    //cout << cnt[0] << cnt[1] << cnt[2] << endl;
    if(cnt[0] > 0){
        ans += cnt[0] - 1;
        if(cnt[1] > 0 || cnt[2] > 0)ans++;
    }
    ans += min(cnt[1], cnt[2]);

    cout << ans << endl;
    return 0;
}


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

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> l(n);
    rep(i, 0, n) cin >> l[i];

    sort(l.begin(), l.end(), greater<ll>());
    ll ans = 0;
    rep(i, 0, k) ans += l[i];

    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    string ans;
    if(n==0)ans = "0";
    while(n!=0){
        int r = n%(-2);
        n /= -2;
        if(r<0)n++;
        ans += to_string(abs(r));
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	unsigned int a[200] = {};
	unsigned int n = 0;
	unsigned int i = 0;
	int count=0;
	short EndFlag = 0;

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

	for (count = 0;0 == EndFlag; ) {
		for (i = 0; i < n; i++) {
			if (0 ==(a[i] % 2)) {
				a[i] = a[i] / 2;
			}
			else {
				EndFlag = 1;
			}
		}
		if(0 == EndFlag)count++;
	}

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

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int w,a,b;
   cin>>w>>a>>b;
   if(a>b)
    swap(a,b);
   if(b<=a+w)
    printf("0\n");
   else
    printf("%d\n",b-a-w);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int s[SIZE], t[SIZE], x[SIZE], d[SIZE];

int main(){
  int N, Q;

  vector<pair<pair<int,int>,int> > timeline;

  scanf("%d%d", &N, &Q);

  for(int i=0; i<N; i++) {
    scanf("%d%d%d", s+i, t+i, x+i);
    timeline.push_back({{s[i]-x[i], i}, 0});
    timeline.push_back({{t[i]-x[i], i}, 1});
  }

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

  int k = 0;

  set<pair<int,int> > ss;

  for(int i=0; i<Q; i++) {
    scanf("%d", d+i);

    while(k < timeline.size() && timeline[k].first.first <= d[i]) {
      int p = timeline[k].first.second;
      int q = timeline[k].second;

      debug(p);
      debug(q);

      if(q == 0)
        ss.insert({x[p], p});
      else
        ss.erase(ss.find({x[p], p}));

      k++;
    }

    auto it = ss.lower_bound({0, -1});

    if (it == ss.end()) {
      printf("-1\n");
    } else {
      debug(it->first);
      printf("%d\n", it->first);
    }
  }


  return 0;
}


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

#define endl         '\n'
#define ll 			long long


int main()
{
  int a , b ;
  cin >> a >> b ;
  if (b > 4 * a) {
    cout << "No" <<endl;
    return 0 ;
  }
  if (b % 2) {
    cout << "No" <<endl;
    return 0 ;
  }
  if ((b % 4 == 0 || b % 2 == 0) && (4 * a >= b && 2 * a <= b) ) {
    cout << "Yes" <<endl;
    return 0 ;
  }
  cout << "No" <<endl;
  return 0 ;
}

Measured memory_bytes: 3624
n=int(input())
A=list(map(int,input().split()))
B=[0]*n
for i in range(n):
  B[i]=A[i]-i-1
B.sort()
b=B[(n-1)//2]
ans=0
for i in range(n):
  ans=ans+abs(A[i]-(b+i+1))
print(ans)

Measured memory_bytes: 26832
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 505;
ll C[MAX_N],S[MAX_N],F[MAX_N];

int main()
{
	int N;
	cin >> N;
	rep(i,N-1)
	{
		cin >> C[i] >> S[i] >> F[i];
	}
	
	rep(i,N-1)
	{
		ll temp = 0;
		for (int j = i; j < N-1; ++j)
		{
			if (temp < S[j]) temp = S[j];
			else
			{
				temp = (temp + F[j] - 1) / F[j] * F[j];
			}
			temp += C[j];
		}
		cout << temp << endl;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
hw = []
buff = []

while True:
    buff = list(map(int, input().split()))
    if [0, 0] == buff:
        break
    else:
        hw.append(buff)

for i in hw:
    for j in range(i[0]):
        for k in range(i[1]):
            if j == 0 or j == (i[0] - 1) or k == 0 or k == (i[1] - 1):
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7004
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define eps 1e-8
const int maxn=2e5+10;
int sgn(double k) {return k<-eps?-1:(k<eps?0:1);}
struct point{
    double x,y,theta;
    point(double a=0,double b=0,double c=0) {x=a,y=b,theta=c;}
    friend bool operator<(const point &a,const point &b) {
        return a.theta<b.theta;
    }
}p[2*maxn];
int n;
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lf %lf",&p[i].x,&p[i].y),p[i].theta=atan2(p[i].y,p[i].x);
    sort(p+1,p+n+1);
    for(int i=1;i<=n;i++) p[n+i]=point(p[i].x,p[i].y,p[i].theta+2*pi);
    int point_=0;
    double sumx=0,sumy=0,ans=0;
    for(int i=1;i<=n;i++) {
        while(sgn(p[point_+1].theta-p[i].theta-pi)<=0) {
            sumx+=p[++point_].x,sumy+=p[point_].y;
            ans=max(ans,sumx*sumx+sumy*sumy);
        }
        sumx-=p[i].x,sumy-=p[i].y;
        ans=max(ans,sumx*sumx+sumy*sumy);
    }
    printf("%.10lf\n",sqrt((double)ans));
}

Measured memory_bytes: 9856
#include <iostream>
#include <stdio.h>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x = y2 - y1, y = x2 - x1;
	int x3 = x2 - x, y3 = y2 + y;
	int x4 = x1 - x, y4 = y1 + y;
	printf("%d %d %d %d\n", x3, y3, x4, y4);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<int> a(n,0);
    rep(i,n) cin>>a[i];
    int q; cin>>q;
    vector<int> m(q,0);
    rep(i, q)  {
        cin>>m[i];
    }
    vector<Int> Ans;
    for(int bit=0; bit<(1<<n); bit++){
        Int ans=0;
        for(int i=0; i<n; i++){
            if(bit&(1<<i)) ans+=a[i];
        }
        Ans.emplace_back(ans);
    }
    sort(Ans.begin(),Ans.end());
    for(int i=0; i<q; i++){
        if(binary_search(Ans.begin(),Ans.end(),m[i])){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 11184
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

signed main(){
  string s; cin >> s;
  set<char> SET;
  for(lint i = 0; i < s.size(); i++) SET.insert(s[i]);
  lint N = s.size();
  if(N == 26){
    if(s == "zyxwvutsrqponmlkjihgfedcba"){
      cout << -1 << endl;
      return 0;
    }
    else{
      int id = -1;
      for(lint i = N - 2; i >= 0; i--){
        if(s[i] < s[i + 1]){
          id = i; break;
        }
      }
			string t = s.substr(0, id);
			int idx2 = id + 1; 
			for(int i = id + 1;i < s.length(); i++){
				if(s[i] < s[idx2] && s[i] > s[id]){
					idx2 = i;
				}
			}
			t += s[idx2];
			cout << t << endl;
		}
  }
  else{
    for(int i = 0; i < 26; i++){
      if(!SET.count(char(i + 'a'))){
        s += (i + 'a');
        break;
      }
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 256
INF=1e10

def prim():
    mincost=[INF]*n
    used=[False]*n
    mincost[0]=0
    res=0
    while True:
        v=-1
        for u in range(n):
            if  not used[u] and (v==-1 or mincost[u]<mincost[v]):
                v=u
        if v==-1:
            break
        used[v]=True
        res+=mincost[v]
        for u in range(n):
            mincost[u]=min(mincost[u],cost[v][u])
    return res

while True:
    n=input()
    if n==0:break
    m=input()

    cost=[[INF]*n for i in range(n)]
    for i in range(m):
        a,b,d=map(int,raw_input().split(","))
        cost[a-1][b-1]=(d-100)/100
        cost[b-1][a-1]=(d-100)/100
    print prim()

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

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

    int ans = 0;
    for(int i=0; i<=9; i++){
        for(int j=0; j<=9; j++){
            for(int k=0; k<=9; k++){
                bool flag1 = false;
                bool flag2 = false;
                for(int l=0; l<n; l++){
                    if(flag2 == true && s[l] - '0' == k){ ans += 1; break; };
                    if(flag1 == true && flag2 == false && s[l] - '0' == j) flag2 = true;
                    if(flag1 == false && s[l] - '0' == i) flag1 = true;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>

int main(){
	int n, k; std::cin >> n >> k;
	std::vector<long long int> num(n); for (auto& p : num) std::cin >> p;
	num.insert(num.begin(), 0LL);
	for (auto i = 1; i < num.size(); ++i) {
		num[i] += num[i - 1];
	}
	long long int max_sum = 0;
	for (auto i = k; i < num.size(); ++i) {
		max_sum = std::max(max_sum, num[i] - num[i - k] + k);
	}
	std::cout << std::fixed << std::setprecision(15) << max_sum / 2.0 << std::endl;
}


Measured memory_bytes: 4736
import kotlin.math.*

fun main(args: Array<String>) {
    val (a, b, h, m) = readLine()!!.split(" ").map { it.toInt() }

    val mr = m * 6
    val hr = (h * 360 + mr) / 12f

    val d = sqrt(a * a + b * b- 2 * a* b * cos((hr - mr) * PI / 180))

    println(d)
}

Measured memory_bytes: 36616
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<string>
#include<stdio.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(), (x).end()
#define lint long long

typedef pair<int,int> P;

const lint MOD = 1000000007;

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

int main(){
    lint n; cin>>n;
    vector<lint> c(64, 0);
    rep(i,n){
        lint a; cin>>a;
        int j = 0;
        while(a > 0){
            if(a % 2 == 1) c[j]++;
            a /= 2;
            j++;
        }
    }
    lint ans = 0;
    rep(i, 65){
        lint a = (c[i] * (n-c[i]))%MOD;
        a *= modpow(2, i);
        a %= MOD;
        ans += a;
        ans %= MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long
#define p(x,y) pair<x,y>
#define pb push_back
#define fo(i,n) for(int i=0;i<(n);i++)
#define mod 1000000007
using namespace std;

int main()
{

ll h,w;
cin>>h>>w;
char a[h][w];

ll dp[h][w];
memset(dp,0,sizeof(dp));
for(ll i=0;i<h;i++)
{
    for(ll j=0;j<w;j++)
    {
        cin>>a[i][j];
    }

}

for(int i=w-1;i>=0;i--)
{


    if(a[h-1][i]!='#')
    {
        dp[h-1][i]=1;
    }
    else
    {
        break;
    }
}


for(int i=h-1;i>=0;i--)
{


    if(a[i][w-1]!='#')
    {
        dp[i][w-1]=1;
    }
    else
    {
        break;
    }
}





for(ll i=h-2;i>=0;i-- )
{
    for(ll j=w-2;j>=0;j--)
    {




            if(a[i+1][j]!='#' && a[i][j+1]!='#')
            {
                dp[i][j]=(dp[i+1][j]+dp[i][j+1])%mod;
            }
            else if(a[i+1][j]!='#')
            {

                dp[i][j]=dp[i+1][j];
            }
            else if(a[i][j+1]!='#')
            {

                dp[i][j]=dp[i][j+1];
            }

            else
            {

                dp[i][j]=0;
            }







    }

}
    cout<<dp[0][0]<<endl;




  return 0;
}


Measured memory_bytes: 9088
#include <stdio.h>
#include <stdlib.h>

typedef struct
{
	long	price;
	int		num;
} t_shop;


int	cmp(const void *a, const void *b)
{
	t_shop *s1 = (t_shop *)a;
	t_shop *s2 = (t_shop *)b;

	if (s1->price < s2->price)
	{
		return (-1);
	}
	if (s1->price > s2->price)
	{
		return (1);
	}
	return (0);
}

int	main(void)
{
	int		n;
	int		m;
	t_shop	shops[100000];
	long	money = 0;

	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
	{
		scanf("%ld %d", &shops[i].price, &shops[i].num);
	}
	qsort(shops, n, sizeof(t_shop), cmp);
	for (int i = 0; i < n; i++)
	{
		if (shops[i].num >= m)
		{
			printf("%ld\n", money + shops[i].price * m);
			return (0);
		}
		else
		{
			money += shops[i].price * shops[i].num;
			m -= shops[i].num;
		}
	}
	return (0);
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	5e5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll vis[MAXN] = {};
/*
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //



ll T = 1;
ll n, x, k, m, r, sum = 0, a, b, l;
string s;

ll dp[80000];


// <------------- Implement Functions Here ----------> //

void solve(ll i, ll j , ll k) {
	ll ans = i*i + j*j + k*k + i*j + i*k + j*k;
	dp[ans]++;
}
// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	for(ll i=1;i<=100;i++) {
		for(ll j=1;j<=100;j++) {
			for(ll k=1;k<=100;k++) {
				solve(i,j,k);
			}
		}
	}
	for(ll i=1;i<=n;i++) cout<<dp[i]<<"\n";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 15792
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    A = int(readline())
    B = int(readline())

    print(6 - A - B)


if __name__ == '__main__':
    main()


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a <= b) {
    for (int i = 0; i < b; i++) {
      cout << a;
    }
    cout << endl;
  } else {
    for (int i = 0; i < a; i++) {
      cout << b;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

isPrime = runSTUArray $ do
    arr <- newArray (1,10000) True :: ST s (STUArray s Int Bool)
    writeArray arr 1 False
    forM_ [2..100] $ \p -> do
        forM_ [p*2,p*3..10000] $ \n -> writeArray arr n False
    return arr

solve n = length [i | i <- [1..n], isPrime!i, isPrime!(n-i+1)]

main = map (solve . readInt) . lines <$> getContents >>= mapM_ print


Measured memory_bytes: 5516
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

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

    cout << 1000 * ((n + 1000 - 1) / 1000) - n << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#define N 100

int main()
{
  int u,k,represent[N][N],i,j,retu,ade;
  while(1)
    {
      scanf("%d",&u);
      if(u>=1 && u<=N)
	break;
    }
  for(i=0;i<u;i++)
    {
      for(j=0;j<u;j++)
	{
	  represent[i][j]=0;
	}
    }
  for(i=0;i<u;i++)
    {
      scanf("%d",&ade);
      scanf("%d",&k);
      for(j=0;j<k;j++)
	{
	  scanf("%d",&retu);	  
	  represent[ade-1][retu-1]=1;
	}
    }
  for(i=0;i<u;i++)
    {
      for(j=0;j<u-1;j++)
	{
	  if(represent[i][j]!=1)
	    represent[i][j]=0;
	  printf("%d ",represent[i][j]);
	}
      printf("%d\n",represent[i][u-1]);
    }
  return 0;
}



Measured memory_bytes: 2132
def answer(a: int, b: int) -> str:
    if a == b:
        return 'EQUAL'

    if a < b:
        return 'LESS'

    if a > b:
        return 'GREATER'


def main():
    a = int(input())
    b = int(input())
    print(answer(a, b))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9080
n,m=map(int,input().split())
ans = [None]*n
for _ in range(m):
    s,c = map(int,input().split())
    if n > 1 and s==1 and c==0:
        ans = [-1]
        break
    
    if ans[s-1] is None or ans[s-1] == c:
        ans[s-1] = c
    else:
        ans = [-1]
        break
else:
    for i in range(n):
        if ans[i] is None:
            ans[i] = 0 if i>0 or n==1 else 1
        
print("".join(map(str,ans)))

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

using i64 = long long;

void rec(i64 head, int append, vector<i64> &lunlun) {
    if (append == 0) {
        lunlun.push_back(head);
    } else {
        int last = head % 10;
        for (int d : {-1, 0, 1}) {
          int t = last + d;
          if (0 <= t && t <= 9)
            rec(head * 10 + t, append - 1, lunlun);
        }
    }
}

int main() {
    vector<i64> lunlun;
    const int size = 10;
    for (int s = 1; s <= size; ++s) {
      for (int h = 1; h <= 9; ++h) {
        rec(h, s - 1, lunlun);
      }
    }
    int k;
    cin >> k;
    cout << lunlun[k - 1] << endl;
}


Measured memory_bytes: 2420
#include<iostream>
#include<map>

int main(){
    int N;
    std::cin >> N;
    std::map<int, int> mp;
    int a;
    for(int i = 0; i < N; i++){
        std::cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for(auto a : mp){
        if(a.second % 2 != 0)ans++;
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 4992